Risk warning: Trading forex, gold and CFDs on leverage carries a high risk of losing money rapidly. Everything on this site is educational and is not financial advice. Never trade money you cannot afford to lose.

HomeLearn › Backtesting in MT5 Without Fooling Yourself

Backtesting in MT5 Without Fooling Yourself

By Zubare Khan · Updated 8 September 2026 · 7 min read · Algo

The MT5 Strategy Tester will happily show you a rising equity curve for a strategy that would have lost money every month it was live. It is not lying — it is answering exactly the question you asked. The skill is in asking a harder one.

Modelling: what the tester is actually simulating

MetaTrader 5 offers several modelling modes, and the difference between them is not cosmetic.

ModeWhat it doesUse it for
Open prices onlyOne price per barFast parameter sweeps on bar-close strategies only. Never for final results
1 minute OHLCGenerates ticks from minute barsRough shape. Intrabar path is fabricated
Every tickGenerates ticks from minute data by an algorithmBetter, still synthetic
Every tick based on real ticksUses the broker's actual recorded tick historyThe only mode whose result means much for anything intrabar

If your strategy touches price inside a bar — a stop, a take-profit, a trailing stop, a breakout level, any grid — then a synthetic tick mode is guessing the order in which the high and the low were reached. That order determines whether you were stopped out before your target was hit, which determines the entire result. On a strategy with a stop and a target both inside one bar's range, synthetic modelling can turn a loser into a winner by assumption alone.

Use real ticks for anything you intend to trade. And be aware of what real ticks actually are: your broker's recorded history, which is often incomplete going back more than a year or two, and which differs from another broker's history for the same instrument.

Spread is where most backtests quietly cheat

This is the largest single source of fake profit in retail backtesting, and it is worst on gold.

Set the spread to “current” and MT5 will test a whole year at whatever the spread happens to be right now. If you press Start on a quiet Tuesday afternoon, you have just simulated a year in which the spread never widened — not for the New York open, not for a payrolls release, not for the Sunday reopen, not once.

Real gold spread is not a constant. It is tight in liquid hours and multiples of that at the session handover and around data. A scalping strategy tested at a fixed tight spread and traded at a real variable one is a completely different strategy with a completely different expectancy.

What to do:

Look-ahead: the bug that makes a strategy look psychic

If a result looks extraordinary, assume look-ahead bias before you assume genius. The usual sources:

A quick sanity check: if the strategy's win rate is above about 85% on a directional method with a stop, something is either repainting, averaging losses (see grid strategies), or reading the future.

Curve fitting, and how to tell whether you have done it

Optimisation finds the parameter set that performed best on the data you gave it. That is its job. The problem is that on any finite history, some parameter set will look excellent by luck alone, and MT5 will find it for you with great efficiency.

The more parameters you optimise, the more certain this becomes. Five parameters over a thousand combinations each is not a search for an edge, it is a search for a coincidence — and it will succeed.

Three defences, in increasing order of usefulness:

Look at the neighbourhood, not the peak

Open the optimisation results as a surface. If your best result sits on a lonely spike surrounded by losses, it is noise: a small change in market behaviour moves you off the spike. If it sits on a broad plateau where everything nearby is also decent, you may have something real. Always prefer a robust plateau to a superior peak.

Hold data back

Optimise on one period, test on a period the optimiser never saw. MT5 has this built in through the forward-testing setting, which splits your range automatically. If in-sample is brilliant and out-of-sample is flat, you fitted noise. This is the single most informative test available and it costs one checkbox.

Walk forward

Repeatedly optimise on a window, test on the next window, roll forward, and string the out-of-sample pieces together. It is slower and much more honest, because it simulates what you would actually have done — periodically re-tuning on recent data — rather than assuming you picked the right parameters once, years ago, by magic.

Test across regimes, not across time

“Five years of data” sounds thorough and often is not. What matters is whether those years contained conditions that are genuinely different from each other: a strong trend, a long range, a volatility shock, a rate-hiking cycle and a cutting one.

Break the result down by year and by quarter rather than reading one aggregate figure. A strategy that made everything in one six-month stretch and went sideways for the other four years is one regime's strategy, not a system. You want to see whether it merely survived the periods it was not designed for, which is a realistic hope, rather than whether it profited in all of them, which usually is not.

Where the platform allows it, run the same test on a second broker's data for the same instrument. Differences in feed, spread and tick history will move your result. If it moves a lot, your edge was inside those differences.

The numbers worth reading

The tester reports a great many statistics. Most are noise. These are not:

Then shuffle. Reorder the trade sequence randomly a few hundred times and look at the distribution of outcomes. The historical order of your wins and losses was luck; seeing the range of drawdowns that the same set of trades could have produced in a different order is far more honest than the single path you happened to get.

Then forward test anyway

Everything above is still a simulation. Before real money:

  1. Run on demo, on the same broker and server you will trade, for long enough to include conditions the strategy dislikes — weeks at minimum, not days.
  2. Compare demo results against the backtest over the identical period. They will differ. The size of the gap is your estimate of how much the simulation was flattering you.
  3. Go live at the smallest size the platform permits, and compare again. Live fills differ from demo fills, particularly on gold around news.
  4. Only then scale, and scale slowly.

The purpose of a backtest is not to prove a strategy works. It is to find the reasons it will not, cheaply, before the market charges you to find them. A test that fails to kill a strategy has done its job; a test that was designed to approve one has not been a test at all.

Zubare Khan
Zubare Khan

I trade gold, forex and index CFDs, sell short-dated option volatility, and build the MT5 and TradingView tools published on this site. Everything here is written from my own screen time and my own losses — not from a content brief. More about how I trade and write.