You are here: Home > Education > Coding your Expert Advisor

5 Things to Know Before Coding Your Strategy

CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. Between 74-89% of retail investor accounts lose money when trading CFDs. You should consider whether you understand how CFDs work and whether you can afford to take the high risk of losing your money.

Retail traders can trade either manually, or with a robot. A robot is also called an expert advisor and can be built or coded to buy or sell a currency pair.

MetaTrader, the most popular trading platform, is giving the possibility to code a strategy. Assuming one is having a technical setup, like buying or selling when technical indicators are showing something, the strategy can be automated so the buying and selling are not made manually anymore.

This way, the trader doesn’t have to be in front of the screens all day, plus, the robot or the EA (Expert Advisor) can trade around the clock. If the conditions are met, the buying and selling take place automatically.

Things to Look for Before Coding an EA

Coding can be done relatively easy, and if the trader doesn’t have programming skills, this job can be freelanced to someone else. However, before coding your own robot, the following things must be considered.

1. Back-test the Strategy

If a strategy works now, or for the last month or months, it doesn’t mean it will work in the future. There is no such thing as the holy grail in any trading strategy, and this must be understood before anything.

Back-testing the strategy is important because it gives traders an idea about the profitability in the past. You’ll be surprised to see what the performance of a good strategy looks when it is back-tested.

EA Expert Advisor trading

Information like the maximum drawdown, how many losing trades in a row, winning ones, etc., are important for future expectations. Coding an EA can be expensive and before paying for it, make sure the strategy is solid.

2. Find a Good VPS Solution

VPS stands for Virtual Private Server and it is a must for any trader that deals with automatic trading. The thing is that the EA will run on a MetaTrader platform if the trading platform is open.

When the computer is closed and the platform closes as well, the robot will not be live anymore, so it will stop trading. To avoid this, and other unexpected situations like power going off and all, a VPS is recommended.

A VPS is your own computer at a different location. These are farm servers rented by different companies under the promise that the computer will never close.

A VPS can be accessed from any location if there is an Internet connection and trading can be monitored in the actual trading account. Hosting a VPS can cost from a few tens of dollars to more than that, depending on the needs and the PC capacity of the computer to be rented.

Some brokers quickly understood this opportunity and are offering free VPS hosting for their customers. This comes as a logical process because brokers will get their money back from the high volume traded by these robots.

3. The Spreads

On paper, it is easy to test a strategy, to see if a profit is made, when, and so on. This is because we consider all things equal, all conditions equal.

This is not the case. Spreads are different during the trading day, for example, and this will impact the execution. If you trade the USDCAD pair and the trade appears at the end of the trading day, the EA will automatically take it. The problem is that this is a currency pair that is less liquid in that period and, for this reason, the spreads are bigger.

If the spreads are bigger, the profitability is not the same as if the same trade would appear during the trading day, when conditions are normal. The EA or the robot doesn’t know that and it cannot trade discretionary.

Most of the trading robots or algorithms are being based on lower time frames, like the one-minute or five-minute charts, up to the hourly time frame. Traders mostly use scalping techniques with these EA’s.

To succeed with these scalping techniques in an automated trading environment, the broker must have low spreads and stable ones. This is difficult to be found these days.

Brokers are intermediaries for the retail customers as they allow retail traders to tap the interbank market. A broker is pairing with liquidity providers to offer the best rates possible.

The more liquidity providers, the better, and the rates will be stable. From now on, if you see a broker that has widening spreads during specific moments in a trading week/day, it means that the liquidity provider cannot offer enough liquidity for that market. The broker needs to add more liquidity providers to offer better rates.

4. The Slippage

Slippage is as important as the spreads in a trading account. Slippage refers to the trade’s execution.

When backtesting a strategy, all conditions are considered equal, which is not correct. Conditions are very different in a trading day or week and because of that, execution is different.

If you assume that the entry point, for example, should be 1.0810 for the EURUSD pair, it could be that the actual entry level is 1.08123. This may be because the market is moving fast due to an economic news.

The broker will execute the entry at the market, but if the market is moving too fast, the entry point can be higher by 2.3 pips as per the example above. If the strategy has ten pips take profit, just like that 23% of the target is lost because the execution was bad.

This is called a slippage, and, ideally, it should not exist in a trading account. Unfortunately, it exists and it affects the performance of a strategy.

5. Associated Costs

If a strategy is profitable, one needs to calculated exactly how much remains at the end of the day in the trading account. Let’s assume on a five-thousand account, an Expert Advisor is making, on average, ten percent monthly profit.

This means a five-hundred profit, but this is before costs. The VPS cost, if any, must be considered, swaps to be paid, commissions, and other costs must be deducted before finding out if the strategy is worth being coded or not.



Compare brokers

Buy Cryptocurrency
SPECTRE
  • The future of Digital Options, Forex and CFD trading
  • Broker-less trading platform
  • Powered by blockchain and a decentralized autonomous liquidity pool
  • Free demo >>
AvaTrade
Blackwell Global
Fortrade
ICMarkets
Itrader
Markets.com
Think Markets



CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. Between 74-89% of retail investor accounts lose money when trading CFDs. You should consider whether you understand how CFDs work and whether you can afford to take the high risk of losing your money.

Our website is free for our visitors, but in order to provide this free service we may be compensated, receive commissions or advertising fees from brokers listed on our website.