Testing an Expert Advisor Properly in MetaTrader

10 min readQuantParadox research

The MT5 Strategy Tester is a capable piece of software with defaults chosen for speed. Every one of those defaults makes a tight-stop EA look better than it is, and none of them announce themselves.

The short answer

Testing an expert advisor in MetaTrader honestly requires every-tick modelling with real tick data, a spread setting that matches live conditions rather than the default, and a walk-forward split, because the tester's defaults resolve ambiguity in the strategy's favour.

Which modelling mode should you use?

Every tick based on real ticks, for any strategy whose stop and target can both fall inside a single bar — which is most of them, and all of them on lower timeframes.

The alternatives exist for speed and they resolve intrabar ambiguity by assumption. "Open prices only" evaluates once per bar and cannot know the path within it; "1 minute OHLC" interpolates a path from four numbers. Both produce a result quickly and neither can say which of your stop and target was reached first.

For a strategy with wide stops relative to the bar size, the difference is small. For a scalper it decides a large share of the trades, and the direction of the error is not random — interpolation tends to produce paths kinder than reality.

The cost of every-tick modelling is time. A multi-year test on real ticks takes considerably longer, which is exactly why the faster modes are chosen and exactly why the results from them should be labelled as provisional.

Where does the tick data come from?

Real ticks in MT5 come from your broker, which means the quality and completeness of the test depend on a source that varies between brokers and is worth verifying rather than assuming.

Check the history for gaps before trusting a result. A tick history missing the fastest minutes — which is where gaps tend to appear — produces a backtest that skipped exactly the conditions most likely to hurt the strategy.

The modelling quality figure the tester reports describes tick density, not validity. A 99.9% figure alongside an in-sample result, an unrealistic spread and the best of four hundred optimiser passes is a precise measurement of the wrong thing.

It is also worth remembering that this is your broker's history, so the test is an estimate for anyone using a different one. That is not a flaw; it is the correct interpretation of the number.

What spread should the tester use?

A realistic fixed spread measured from your own account, or variable spread from the tick data — never the tester's minimum, which represents the best conditions rather than the typical ones.

The default behaviour of using the current or minimum spread is the single most common source of an over-optimistic EA result. It applies the tightest quote in the record to every trade including the ones taken during news and rollover.

Sampling your own spread by hour across several weeks and using a value from the middle of that distribution is a large improvement for very little work. Using the real variable spread from tick data is better still where the data supports it.

Commission belongs alongside it and is separately configured. An EA tested with realistic spread and zero commission on a raw-spread account is missing a per-lot charge that applies to every trade.

How should you use the optimiser?

As a search whose trials you count, not as a way to find the right settings — because the optimiser's job is to return the best of many, and the best of many looks good whether or not an edge exists.

MT5's optimiser will happily evaluate tens of thousands of combinations and report the winner. That winner is a maximum drawn from a distribution, and the gap between it and the truth grows with the number of combinations evaluated.

The forward-testing option in the tester is the tool that addresses this, and it is worth using deliberately rather than as a checkbox: optimise on the earlier portion, then run the chosen settings ONCE on the reserved later portion and accept that number.

Watch the optimisation surface as well as the peak. A parameter set surrounded by other settings that also work describes a broad, plausible region; a lone spike surrounded by failures describes a fit to specific historical accidents, and it is the spike that the optimiser will hand you.

What does the tester not model?

Latency, requotes, partial fills, and the difference between a demo server and a live one — all of which sit between a passing backtest and a working EA.

The tester executes instantly at the modelled price. Live, there is a round trip during which the market moves, and for a strategy whose target is a handful of pips that round trip is a meaningful fraction of the edge.

Requotes and rejections do not appear at all. An EA that assumes every order is accepted is modelling a broker relationship rather than a market, and the difference shows up during exactly the fast conditions the strategy may be designed to trade.

The practical answer is a period on a live account at minimal size after the backtest passes — not as a second validation of the edge, which the backtest already addressed, but as the only way to measure the things the tester structurally cannot.

Questions people actually ask

Is 99.9% modelling quality enough to trust a backtest?

It confirms the tick data was dense, and nothing else. The result can still be entirely in-sample, use the tester's minimum spread, omit commission, and be the best of thousands of optimiser passes. Modelling quality is necessary for a trustworthy intrabar result and nowhere near sufficient for a trustworthy conclusion.

Why does my EA perform differently on a different broker?

Because the price history, the spread structure, the execution model and the server time zone all differ. Server time is the most commonly overlooked: a strategy referencing session boundaries or daily candle closes is referencing different bars on a broker whose day is cut at a different hour, which changes which levels are being traded.

Should I use genetic optimisation or a full search?

The choice affects how thoroughly the space is explored and not the underlying selection problem — both return a best-of-many. What matters more is reserving a period the optimiser never touches and grading the chosen settings there exactly once, and recording how many combinations were evaluated so the result can be interpreted as the maximum it is.

The only backtest that settles it is yours.

Build a strategy from a sentence, paste your own Python, or import your live trade history and have it graded. Five full backtests free, no card, and we'll tell you plainly when the result is indistinguishable from luck.

We publish research and tooling, not trading advice, and we make no claim about future returns. Everything above describes how to test an idea — not a reason to trade one.