$ £ ¥
¥ £ $

How to Backtest in MetaTrader 4 Strategy Tester

One of the greatest features in MetaTrader platform is the possibility to backtest an expert advisor or an indicator. This is also one of the reasons why MetaTrader 4 is so popular. In this guide, you will learn what the meaning of backtesting is and how to backtest your strategies and expert advisors in MetaTrader 4 (MT4) Strategy Tester.

 

What Is Backtest in MetaTrader 4?

What does backtesting mean? A backtest of an expert advisor means running the expert advisor on historical data. Basically, you can see how the expert advisor would have behaved in the past. If properly done, backtesting can give you a good idea of the potential performance of an expert advisor.

When talking about backtesting, it is always important to remember that past performance does not guarantee future results. We can expand it a little to make it easier to understand: assume that you backtest an expert advisor and it is absolutely amazing — it has a gain of over 100% in 1 year and a drawdown of only 1%; this is just the backtest and it does not mean that the next year it will do the same — it could actually lose money, so always remember, for every trading strategy and expert advisor, what it did in the past does not indicate what it will do in the future.

Advantages of Backtesting

Backtesting an expert advisor brings many benefits, some of them are:

  • Testing the potential of a strategy — this is maybe the most important benefit. You may have an idea for a trading strategy, but testing it manually would take too much time. If you can develop an expert advisor that trades your strategy, you can backtest it on various timeframes, various instruments, and various market conditions (trending, ranging. and so on) and see if the strategy has any potential.
  • Find errors in your expert advisor — it doesn't matter how good a coder someone is, we all make errors when coding. Running a backtest of an expert advisor will allow you to spot bugs and correct them before running it on a demo account. Running a test on 1 year worth of data in a few seconds is much faster than actually waiting a year to verify it in trading account.
  • Gather more information about the possible results — it is true that past results do not guarantee future outcomes, but running a backtest can give you useful statistics about the possible results of an expert advisor. For example, you can get total profit/loss, number of trades executed, percentage of trades won and lost, drawdown, and many other metrics for the period you test it on.
  • Detect weaknesses in the strategy for possible improvement — backtesting can indeed show you when orders are opened and closed and you can adjust your strategy to improve the entry and exit triggers.
  • Test a product that you bought — if you buy a commercial EA or download a free one from some website, always backtest it first!

Disadvantages of Backtesting

Backtesting unfortunately has some disadvantages:

  • Behavior on a real account may differ from backtesting — this is due to the broker's execution quality and the real-time communication with the server.
  • As already mentioned past performance does not guarantee future results — so, you should always take the results obtained from backtesting with some doubt. Generally speaking, an expert advisor performing poorly during backtesting hardly will perform well on a real account, while an expert advisor performing well on backtesting can have some possibility of successful trading in real conditions.
  • Backtesting requires quality raw data — we will talk more about this further, but for now, we can just say that backtesting can be reliable only if run on accurate raw data, usually tick data.

How to Backtest in MT4?

Backtesting is a very simple process. Open the Strategy Tester in MetaTrader 4 (Ctrl+R), select the expert advisor to test from the drop-down list, select the currency pair and timeframe, select the dates of start and end, set the input parameters for the expert advisor, and press Start button. MetaTrader will run the expert advisor on the historical data and present the results.

MT4 Strategy Tester Interface Layout
Select EA, Instrument, Timeframe, Start and End Dates
Expert Properties in MT4 Strategy Tester
Enter Input Parameters for EA via Expert Properties
Trading History Report in MT4 Strategy Tester
List of Executed Orders
Balance Graph in MT4 Strategy Tester
Balance Graph
Backtesting Statistics in MT4 Strategy Tester
Backtesting Statistics
Backtesting Journal (Log) in MT4 Strategy Tester
Journal/Log
Saving Backtesting Report in MT4 Strategy Tester
Right-Click the Report to Save It as File
HTML Report Produced by MT4 Strategy Tester
Report File Can Be Viewed in Web Browser
Trade Execution Chart in MT4 Strategy Tester
Chart with Executed Trades Overlay

Historical Data

It is important to have accurate and complete historical data, otherwise the backtest will not be reliable. You can learn more about getting high quality historical data for accurate backtesting with MetaTrader 4 from our dedicated tutorial on MetaTrader historical data.

Conclusion

Backtesting means testing a trading strategy or an expert advisor on historical data. MetaTrader 4 provides a very simple and fast way to do it automatically via the Strategy Tester. Make sure to test your strategy before running it on a demo or real account. Also, make sure to use quality historical data or your results will not be reliable.

If you want to get news of the most recent updates to our guides or anything else related to Forex trading, you can subscribe to our monthly newsletter.