2 Backtesting Pitfalls to avoid in MT4

By | February 25, 2019

In Summary:

  1. Avoid designing an EA to trade 5min and lower time frame
  2. Avoid designing an EA to go for small profits


  1. Differences between broker data can be significant on lower time frames
  2. Slippage becomes a significant percentage of profits, when your average profit target is small


  1. Backtest using your broker’s actual tick data. Or design your EA to trade 15min time frame and above
  2. Do not go for small profit targets

Beginner Pitfalls – Trading too small a timeframe

I recently had a discussion with a buddy who just got started in algo trading in MT4. He was sharing with me how he wanted to create an EA that could trade the 1 min charts, and trade with relative high frequency, so that he could see the money rolling in daily. Are you also like him? Do you have a similar thinking? Me too, when I first started dabbling in the world of EAs.

The problem with his suggestion is that he wanted to trade too low a time frame (1 min). This poses a problem for execution and back testing.

1. Avoid designing an EA to trade on lower than 15 minutes time frames

Why? – Slippage

The lower your time frame, the faster your execution needs to be. This is because slippage plays a bigger factor the lower your time frame. When you trade 4 hour charts, you will most likely be going for a profit target of at least 50 pips or more. If you get a 5 pip slippage, 10% of your profits are eroded.

On a 1 min chart, you might only be going for 10 pips of profit. And slippage doesn’t care whether you trade 4 hour or 1 min charts. It will still be the same (5pips in this case). But this time, slippage is 50% of your profit. That’s a lot of profit given away.

Can you also imagine, that if you have a 10pip stop loss on a 1min chart, and you receive a 5pip slippage? You might risk 2% of your account on the 10pip trade, but because of slippage (5pips), you inadvertently lost an extra 50%, i.e. 3% instead of 2% now?

I am trying to highlight the dangers of trading on too low a timeframe, and that danger is primarily slippage. Unless we have a super fast execution (i.e. colocation and using a faster programming language than MQL4, we should trade higher timeframes, or 15min and above)

Real Life Story – Million Dollar Pips

There was an EA (Million Dollar Pips) back in 2011 that traded strong breakouts from the bollinger band on the 1 min chart. This EA would fade the breakout (trade against the direction of the breakout), betting that the breakout will fail, and prices would go back into the bollinger band.

If we set the bollinger bands to 3 standard deviations, this means that 99.7% of the time, prices should remain in the bollinger band right? So this EA should work in theory right? Yes, but because of slippage, it didn’t.

Mechanism of EA

  1. When bar size is greater than 30pips
  2. And price is above 3 Standard deviation of bollinger band
  3. The EA will short, betting prices will revert to within the bollinger band.

In our photo, it turned out to be a profitable trade. In fact, it sounds like a solid strategy. The only problem is that one will encounter slippage, and that will kill the strategy, as highlighted above.

When the EA was launched in 2011, traders were making a lot of money from this EA on a broker (Go Markets Australia) where this EA worked very well. The reason why it worked, was because the broker was B booking all of its clients, and there was no slippage. B booking means the broker takes the other side of the trade, and therefore is able to give an artificial slippage-less environment.

It worked so well that the broker almost went into receivership, because a lot its clients were winning using this EA (people got to know about the EA and the broker through successful myfxbook accounts), and the broker was taking the other side of the trade, and had to pay for the losses.

This is also why you will see that the EA works on a demo account, but not in a live environment, because the demo environment in MT4 is slippage-less.

2. Another reason to avoid trading on 15 minute time frames and lower

Why?- The lower the time frame, the more significant the differences become in backtest data between different brokers.

This means you may not be able to accurately backtest your strategy

5mins timeframe, Axitrader and Global Prime

15min timeframe of the same area as above, Axitrader and Global Prime

In the top 5min chart above, you will notice that there are differences in the close prices between both brokers. Partly, this is due to it being just after the rollover, and in the early hours of the asian session, where the markets are more illiquid, resulting is different quotes from broker’s liquidity providers

This has resulted in a big difference in the stochastic indicator readings. Both stochastic indicators have the same settings. So imagine if you had a condition that would trigger a buy trade if stochastics fall below 20. (white bottom dotted line). The right picture would trigger a trade, while the left won’t.

This will result in backtesting differences, and relative inaccuracy of your backtest, compared to your broker.

What is the solution?

You will have to backtest using your broker’s actual price data, by collecting tick by tick data (There should be an EA on the internet that will do this), or downloading MT5, and downloading your broker’s tick data from that platform. Then upload it to Birt’s Tick Data suite.


Please view this comprehensive guide

Solution 2

Instead of downloading Tick data from MT5, you can just design your EA to trade on 15mins timeframe or above. You will notice in the 2nd lower picture above, that on the 15mins timeframe, the 2 stochastic indicators give almost identical readings. This is despite some minor differences in close price between both brokers.

This shows that 15mins timeframe or higher is a good timeframe to trade your EAs on, if you want an accurate backtest, despite using another broker’s tick data (which might be more easily available – like Ducascopy). Ducascopy tick data comes default with Tick data suite.

Solution 3

Finally, avoid designing your EA to go for small profits < 10pips, as explained above. This is because slippage becomes a big percentage of your profit, and slippage is not something you and I can control in general.

I hope this article has truly benefited you! I truly enjoyed writing it and tweaking this article to be as beneficial as possible!


Leave a Reply

Your email address will not be published. Required fields are marked *