How to Backtest a Forex EA on MT4

Backtest a forex EA on MT4 – how it works

backtesting forex chart

To backtest forex EAs is an extremely fun thing to do and some traders are getting addicted to it. Even I admit to having tested countless EA’s. For hours my home office heard the famous “BEEP BEEP”. Once you start using expert advisors its tempting to find for the ultimate settings of your EA.
We offer a price action ea that is perfect for this “no risk hobby”. Feel free to ask for a demo so you can try it yourself.

But first, lets get something terribly wrong out of the way..

I am sure that you experienced the “holy grail EA” feeling after an extremely successful back test. Don’t pop the champagne…yet.. Just know that a back test is absolutely no guarantee that a forex strategy will be profitable in a live trading account. So all it does and why I use it, is to see if the trading rules apply. I hope that this post will help you taking your robot trading to the next level.

I will explain about the following topics:

What is Back testing?

Backtesting forex strategies is the process of testing a trading strategy on historical data. It will show you how the strategy would have performed in the past using all available tick data. Many traders that use ea’s believe in the theory that if a system performed well in the  past it will also do well in the future. Today I will explain in detail how to use the strategy tester in your Metatrader 4 terminal. It’s designed to back test your automated strategies.

Just remember this

If the back test was positive at least it gives hope for the forward test of the strategy in a live account. For example, you can compare a back test with a rear mirror in your car. You can see all traffic behind you but you will never be able to predict what will happen in front of you.

Does a Backtest help me?

Yes, most definitely. First of all you cannot lose money if you backtest forex strategies. What I mostly like about it is that it gives me a lot of insight in how the EA behaves in different market situations. Not that it is any guarantee that it works the same in a live account, but you don’t want to trade a strategy with poor backtesting results.

Tick data and how important is it?

Tick data is an important factor performing a back test. Especially for scalping strategies its important to retrieve as close as 100% of the tick data as you can get. For most other strategies a 90% is common. The Metatrader 4 platform usually provides over 90% of historical data.

A standard backtest forex procedure on MetaTrader 4 terminal uses the data from the MT4 history center and usually is sufficient for Expert Advisors (EA) that are not scalping. However, a scalping EA that closes trades within 1-15 pips, even the smallest price change can create a huge difference. So to understand the specific impact you should consider to work with a professional backtester.

I will explain about how the mt4 strategy tester works, but below you can see where you can check how much tick data is available.

strategy testerAlthough tick data is important I think you can back test any ea in your mt4 terminal. Some commercial websites offer up to 99.9% historical data and yes, it is better. Understand that this tick data is not for free and your big question will not be answered either. Will my EA perform well in a live account? 

Only in case you want to back test a scalping strategy its recommended to use a professional tick data provider.

What is curve fitting?

For new auto traders this information will be useful. Many traders rely on a strategy, the developer and unfortunately also on the back test reports. But did you know that these reports can be completely rigged? Let me explain how this works.

If you were the developer, wouldn’t you want to show the ultimate results for your strategy? You would want to show the highest profit. Now a developer will look at more than just profit, and test for lowest drawdown or most winning months, for example; the developer will code the EA in a way that the best performance will appear. The problem is, just because one parameter worked on the past data does not mean it will work on the future, unknown data. So how would a developer attempt to avoid such a problem?

Another example of curve fitting is adjusting parameters. Imagine a trading strategy that is doing well. However it suffers big losses on most Thursday evenings.  A developer might look at those results and come up with a plan, code the system not to take any trades on Thursdays after 1800 pm. Running the code backwards after putting in the new logic would result in those Thursdays losing trades going away, and there you go – you have a good strategy.

Is backtesting software a good idea?

Yes, in some cases. For a while I was obsessed by scalping trading strategies and since these systems take small gains its very important to have correct tick data. Since most brokers and liquidity providers not always like scalpers I kind of lost my interest in these strategies. Although we are backtesting forex strategies, we try not to show it on this website. It could give a false impression of the real deal… a live trading test.

The biggest pitfall of backtesting is the lack of market slippage and gaps. Using professional backtesting software will reduce the foul trades, but will never be 100% accurate. During trading sessions prices will show slippage and also misquotes will not be visible during backtesting forex strategies.

How to backtest a forex strategy in MT4?

Before to backtest a forex ea its important to set up the strategy tester correctly. For example, you don’t want to fool yourself with a very low spread, so best to select a 3 pip spread. If the test is doing well on 3 pips, it can only get better if the spreads are lower. Besides the spread, make sure you are using the correct Period (M15 in the example) and that you use the correct expert properties.


Another very useful feature is to backtest in visual mode. This will make the test take longer, but the chart will run alongside the trading strategy. So in this case you can see each entry and exit.

If you experience an error you can go to the “Journal” in the bottom tab bar of the strategy tester. In case you are not an MQL programmer, share this error report with your EA developer. Most errors are easily fixed.

Below we show you a video of how to use the strategy tester in the MT4 platform.

How Do I Analyze My Backtesting Results?

After your backtest is completed you can download the results as a report. Put you cursor on the strategy tester and right click your mouse.

strategy tester

Once you downloaded the report you can save it as a file. It will show each and every trade made with settings, entries, stop outs etc. What I usually do is saving each report with different settings. Because I am trying to find the “ideal” settings for the strategy. Call me old fashioned but I just love to analyze with a piece of paper and color marker. Bear in mind that ideal settings do not necessarily mean that they will work well in a live trading environment too. Forward testing is still the only way to rule out any issues with the strategy.

Fun fact: some forex robot strategies do better in live trading than in the backtest.


Backtesting forex strategies is not a waste of time. In fact, backtest are the perfect tool for checking the coded EA. Many developers create little mistakes (bugs) which can be resolved with a risk free backtest. In case you are stepping up the forex robot game with more sophisticated EAs, it’s useful to find a good tick data provider. For under $100 you should be able to download up to 99% tick data of your preferred currency pair. Backtesting forex strategies is fun and will teach you a lot, so by all means keep on testing those bots!

You might also want to read this article:

Best Forex Robot that Craves for Pips in October 2018 

Leave a comment

You must be logged in to post a comment.