Blog · Research · 7 min read

How to Backtest an EA in MT5 Strategy Tester (the Right Way)

To backtest an EA properly in the MT5 Strategy Tester, use "Every tick based on real ticks" where your broker provides the data, test across several years and market conditions, include realistic spread and delays, and keep part of the data aside as an out-of-sample check. Then judge the report on profit factor, drawdown and the number of trades, not on the final balance.

Why most EA backtests are misleading

A backtest answers one question: how would these rules have behaved on this data, under these assumptions? Every weak assumption makes the answer less useful.

The common problems are:

Advertisement
  • Unrealistic price data, so entries and stops fill at prices that never traded.
  • Zero or tiny spread, which flatters short-term strategies.
  • Short test periods that cover only one type of market.
  • Overfitting: settings tuned until the past looks perfect.
  • Too few trades to separate skill from luck.

Choosing the right tick model in MT5

The Strategy Tester offers several modelling options. They trade speed for accuracy.

Model How prices are built Best use
Every tick based on real ticks Broker's recorded tick history Final tests; anything sensitive to stops and spread
Every tick Ticks generated from 1-minute bars Useful when real tick history is missing
1 minute OHLC Only open, high, low, close of each M1 bar Fast screening of ideas
Open prices only Only bar opens EAs that act only on new bars, early optimisation

For gold, the difference matters. Gold can move several dollars inside a minute. With 1-minute OHLC, the tester cannot know whether the high or the low came first, so a trade that hit both stop and target in the same bar may be scored wrongly.

A practical workflow: screen ideas with 1-minute OHLC, then confirm anything promising with real ticks. Check the history quality figure in the report. If real tick data is patchy, results are less reliable.

Spread, slippage and delays

Costs decide whether many strategies make money at all.

  • Spread. In real-tick mode, spread comes from the recorded bid and ask, so it reflects your broker's conditions, including wider spreads around the daily rollover and news. In generated modes, check how spread is taken from the history and whether it looks realistic for your account type.
  • Commission. Make sure the tester account type matches your live account, including commission per lot.
  • Delays. MT5 lets you add execution delay in the settings. Test with some delay, not just zero latency, especially for EAs that trade fast moves.

Our own research backtest on gold applied spread and slippage to every trade. That is the minimum standard. If an EA only works with zero cost, it does not work.

Picking date ranges that mean something

A test period should include more than one kind of market: trending, ranging, high volatility and quiet phases. For gold, the last few years have included strong trends and multiple record highs in 2024–2025, as well as choppy periods.

Guidelines:

  1. Use several years where the data allows. Our own gold research covers July 2022 to September 2026, about 98,000 M15 candles.
  2. Look at results by year and by month. A strategy that made all its money in one quarter is fragile.
  3. Include recent data, because spreads and volatility change over time.

In our backtest (hypothetical), all five calendar years from 2022 to 2026 were positive and about 71% of months were profitable. That kind of breakdown tells you more than a single total.

Out-of-sample and forward testing

In-sample data is what you used to design or optimise the EA. Out-of-sample data is data the EA has never "seen". Only the second is a fair test.

MT5 has a built-in Forward option in the tester settings. It splits your date range and runs the optimised settings on the later part automatically. Use it whenever you optimise.

A good process looks like this:

  1. Optimise on the earlier part of the data.
  2. Run the chosen settings unchanged on the later part.
  3. Compare the two. A strong drop in profit factor or a big jump in drawdown is a warning.
  4. Then run on a demo or small live account and compare again.

How to spot overfitting

Overfitting happens when settings describe the noise in past data rather than a real pattern. Signs include:

  • Many inputs, each finely tuned.
  • Results that collapse when one input moves slightly.
  • One or two huge trades providing most of the profit.
  • An equity curve that is almost too smooth.

We saw the outlier problem directly in our own research. One tight-stop version of our gold model looked excellent, but only because of a single +68R trade. Most tight-stop versions earned roughly half the return with two to three times the drawdown.

Two tests help:

  • Parameter stability. Change key inputs up and down. Good strategies degrade gently.
  • Random comparison. Compare the strategy with random entries using the same exits and risk. Our final model beat 400 random-entry runs; if yours cannot beat random, the edge is doubtful. Our guide to backtesting ICT concepts covers this in more detail.

Reading the Strategy Tester report

Focus on these numbers:

  • Total trades. Fewer than about 100 trades gives a wide range of possible "true" results. More is better.
  • Profit factor. Gross profit divided by gross loss. Above 1 is profitable; treat very high values from small samples with suspicion.
  • Equity drawdown maximal and relative. Equity drawdown includes open losses and is closer to what you will feel.
  • Expected payoff. Average result per trade.
  • Consecutive losses. Use this to size risk so a normal losing streak does not breach your limits.

An example with our own tests

For reference, our MT5 Strategy Tester runs on a $10,000 account from January to September 2026 (hypothetical) produced:

Setting Return Equity drawdown
Core model, 2% risk +50% 9.2%
With Free Add, 2% risk +89% 10.9%
With Free Add, 1% risk +32% 5.3%

The 1% run had a profit factor of 4.28, but that is a nine-month window. The longer four-year research on the performance page shows a profit factor of 2.71 over 146 trades, which is the more reliable figure. Short windows often look better than the long run.

After the backtest: compare with live results

A backtest is a hypothesis. The test is whether live trading behaves similarly. Keep a record of live trades and compare win rate, average R and drawdown with the backtest. That is why we publish a public live results page that updates automatically, losses included.

FAQ

Which MT5 tick model is most accurate?

"Every tick based on real ticks" is the most accurate, because it uses the broker's recorded tick history. It is slower, so many traders screen with 1-minute OHLC first. Confirm final results with real ticks.

How many trades do I need for a reliable backtest?

There is no magic number, but a few dozen trades is rarely enough. Aim for at least around 100 trades across different market conditions. With fewer, small changes in luck can swing the results a lot.

What is a good profit factor for an EA?

Above 1 means the EA made money in the test, after the costs you included. Values that stay well above 1 across years and out-of-sample periods are more meaningful than a single very high number. Be sceptical of extreme values from short tests.

How do I avoid overfitting an EA?

Use few inputs, test on out-of-sample data, and check that results stay reasonable when you change settings slightly. Compare against random entries. If most profit comes from one or two trades, treat the result as luck until proven otherwise.

This article is educational and not financial advice. Trading gold and leveraged products carries a high risk of loss.

Tradedge Pulse

Trade the tested model

Live XAUUSD signals, an MT5 indicator and a fully automated MT5 EA, all from one tested rule set.

Trading involves substantial risk. This is educational content, not financial advice. See the risk disclosure.

Tradedge Pulse
Written by Fuzail Naqash

Published by Tradedge Pulse, a gold trading research site founded by Fuzail Naqash. We test trading ideas on years of XAUUSD data before we write about them.

About Tradedge Pulse →

Keep reading