MetaTrader 5 Strategy Tester: modes, tick data and how to avoid overfitting
A practical walk-through of the MT5 Strategy Tester: which tick mode to pick, what real ticks change, how costs and delays are modelled, how to read the report, and how optimisation quietly turns into curve-fitting.
- The MT5 Strategy Tester runs an Expert Advisor over historical data in one of five modes; "Every tick based on real ticks" is the closest to live conditions when your broker provides the data.
- Generated-tick modes invent price movement inside each bar, which can flatter strategies with tight stops and targets.
- Check that spread, commission and swaps were actually applied in the report; a test without realistic costs answers the wrong question.
- Optimisation tests thousands of settings and picks the best, so the top result is partly luck; the built-in forward period is the first defence against that.
- A good tester result is a reason to forward test on a demo, not a reason to trade real money.
The MetaTrader 5 Strategy Tester runs an Expert Advisor (EA) over historical prices and reports what it would have done: every trade, the balance curve, drawdown and a page of statistics. The most important setting is the tick mode, because it decides how realistically price movement inside each bar is reproduced; "Every tick based on real ticks" is the most faithful, "Open prices only" the fastest and crudest.
The tester is a good tool for finding out whether a set of rules is broken. It is a poor tool for proving that a set of rules will make money, and its optimisation feature makes it very easy to fool yourself. This guide walks through the settings, what each one changes, and the habits that keep a test honest.
What the Strategy Tester is for
The tester runs code, not ideas. It needs an Expert Advisor, an indicator or a script written in MQL5. If you trade by hand and want to test a discretionary method, the manual approach in our guide on how to backtest a strategy is a better fit. If you are new to automated trading in general, start with Expert Advisors and trading bots, which covers where EAs come from and the designs that hide risk.
What the tester does well:
- Checks that the code does what you think. Watching an EA trade in visual mode is the fastest way to catch an inverted condition, a stop that is never placed, or a lot size calculated in the wrong units.
- Measures how a fixed set of rules behaved on past data, including drawdown, trade count and the distribution of results.
- Compares variations under identical conditions, which is useful as long as you remember that the past data is the same for every variation.
What it cannot do is tell you how the market will behave next. Markets change regime: volatility rises and falls, central banks move rates, liquidity thins in some years and deepens in others. A test on one period describes one period.
The tester is also one of the clearest practical differences between the two MetaTrader versions. MT5's tester is multi-threaded, handles strategies that trade several symbols, and can use real tick data, as our comparison of MetaTrader 4 vs MetaTrader 5 explains.
Opening the tester and the main settings
Open it from the View menu (Strategy Tester) or with Ctrl+R. The Settings tab is where almost every decision is made. Working through it from top to bottom:
- Expert. Choose the EA from the list. Only compiled programs in the MQL5 folder of the terminal's data directory appear.
- Symbol and timeframe. The symbol must match how your broker names it (EURUSD, EURUSD.r, EURUSDm and so on). The timeframe is the chart period the EA is attached to; the EA can still request data from other timeframes.
- Date range. Pick a period long enough to include different conditions: trending and ranging phases, quiet and volatile months, and ideally at least one stressful episode.
- Forward. Splits the date range so the last part is held back as an out-of-sample check during optimisation. More on this below.
- Delays. Simulates the time between the EA sending an order and the order being executed.
- Modelling. The tick mode, covered in the next section.
- Deposit, currency and leverage. Set these to match the account you would actually trade, not a round number that makes the curve look smooth.
- Optimisation. Off for a single test, or one of the optimisation types if you want the tester to search through parameter values.
The Inputs tab holds the EA's own parameters, such as indicator periods, stop distances and risk per trade. Tick the visual mode box when you want to watch the test run on a chart; leave it off when you want speed.
The five modelling modes
MetaQuotes documents five modelling modes. They differ in how much price detail the tester sees inside each bar.
Every tick based on real ticks
The tester replays the actual ticks your broker recorded, bid and ask, with no simulation. Spread varies exactly as it did in the recorded data, including the widening around news and the daily rollover. This is the closest the tester gets to live conditions.
The limits are practical. Real tick history is large, so the first run can be slow while the terminal downloads it from the broker's server. Coverage depends on the broker: some hold years of tick history for majors and much less for exotics or CFDs. If ticks are missing for part of the period, the tester fills the gap with generated ticks, and the report's history quality figure tells you how much was real. Different brokers' tick data can also produce different results for the same EA, because their prices and spreads were not identical.
Every tick
The tester generates ticks from one-minute bars using a fixed algorithm. It knows the open, high, low and close of each minute and fills in plausible movement between them. This is far better than nothing for most strategies, but the path inside each minute is invented.
1 minute OHLC
Only the four prices of each one-minute bar are used. It is much faster and adequate for strategies that act on bar closes and use stops and targets well away from entry.
Open prices only
The EA is only called at the open of each bar on the test timeframe. It is extremely fast and useful for rough screening, but only valid for EAs written to act once per bar. If the EA manages stops or exits inside the bar, this mode gives meaningless results.
Math calculations
No price history at all. This mode is for testing pure calculations or custom logic; it is irrelevant for normal trading EAs.
Why the mode matters: the same bar, two stories
Suppose an EA buys EUR/USD at 1.1000 with a 10-pip stop at 1.0990 and a 10-pip target at 1.1010. Inside a single one-minute bar, price touches both 1.0990 and 1.1010 (an illustrative but common situation during a data release).
With generated ticks, the tester has to guess which level was touched first. Depending on how the bar is constructed, the trade may be booked as a winner. With real ticks, the tester knows the order: if the low came first, the trade lost. Across hundreds of trades with tight stops and targets, those guesses can turn a losing system into an apparently winning one. The tighter the stop relative to the bar range, the more the mode matters, which is why scalping EAs should only ever be judged on real ticks.
Delays, spread, commission and swaps
Execution delay
MT5 offers no delay (ideal execution at the requested price), a random delay, or a fixed delay you set, and it can measure your ping to the trade server and use that figure. Running at least one test with a realistic delay is worthwhile for any strategy that enters on fast moves. If the result changes materially with a delay of a fraction of a second, the strategy depends on execution you probably will not get. Our guide to slippage explains why live fills drift from requested prices.
Spread
In real-tick mode the spread is whatever was recorded. In generated modes it comes from the spread information stored with the bar data, which is less precise and can miss the brief spikes that hit tight stops. If you are unsure, compare a generated-tick run with a real-tick run over the same period and look at the difference in results.
Commission
Commission is not automatically included in every setup. Whether the tester charges it depends on how the symbol is configured on your broker's server. After a test, open the report and check the commission line. If it is zero and your account type charges commission per lot, the result is overstated by the commission on every round trip. You can subtract it manually, or create a custom symbol with commission settings that match your account. Our guide on how to compare trading costs shows how to turn a spread and commission into an all-in cost per lot.
Swaps
The tester applies swap charges using the symbol's swap settings, so historical changes in interest-rate differentials are not reproduced. For a strategy that holds positions for weeks, that can make a large difference. Our guide to swap and overnight financing covers the triple-swap day and how swaps are calculated, and the swap calculator lets you estimate the cost of a typical holding period to set against the test.
Worked example: what costs do to a scalping EA
These numbers are illustrative. An EA trades EUR/USD with 0.10 lots, 400 trades over a year, and the tester report shows a net result of $1,200 before you check the cost lines.
- On closer inspection, the commission line is zero, but the live account charges $7 per standard lot round trip, so $0.70 per 0.10-lot trade. Over 400 trades that is $280.
- Running the same test with real ticks rather than generated ticks reduces the result by a further $500, because the real spread around news was wider and several tight stops were hit first.
- A fixed execution delay matching your measured ping costs another $250 in worse fills.
The adjusted figure is $1,200 − $280 − $500 − $250 = $170 for a year of 400 trades. The headline result was about seven times the adjusted one. Nothing about the strategy changed; only the assumptions did.
Reading the report
The Backtest tab shows the summary statistics, and the Graph tab shows the balance and equity curves. The figures that matter most:
- History quality. How much of the test used real data. Anything other than close to 100% in real-tick mode means part of the test was simulated.
- Total net result, gross gains and gross losses. The ratio of gross gains to gross losses is the profit factor. Our guide to profit factor and trading metrics explains what each statistic does and does not tell you.
- Balance and equity drawdown. Equity drawdown includes open losses, so it is the more honest figure, especially for EAs that hold losing trades for a long time. Our guide on drawdown and recovery shows why a 50% drawdown needs a 100% gain to recover.
- Total trades. Fewer than a hundred or so trades tells you very little about a strategy's real character, whatever the other numbers say.
- Largest loss and maximum consecutive losses. These are what you will actually live through.
- Expected payoff. The average result per trade. Compare it with your all-in cost per trade: if costs are a large fraction of it, small changes in conditions will flip it negative.
Two curve shapes deserve suspicion. A perfectly straight balance line with a sagging equity line usually means the EA holds losers open while banking small wins, the signature of grid and martingale designs. A curve that rises steadily and then breaks sharply at the end of the period often means the strategy was tuned to the earlier data.
Once you have the drawdown and win rate, the risk of ruin calculator and the drawdown calculator put them in terms of what could happen to a real account at a given risk per trade.
Optimisation: the feature that does the most damage
Optimisation lets the tester run the EA many times with different parameter values and rank the results. MT5 offers a slow complete algorithm (every combination), a fast genetic algorithm (an evolutionary search that tests a subset), and a mode that runs one set of inputs across all symbols in Market Watch. The genetic algorithm ranks results by a criterion you choose, such as maximum balance, maximum profit factor, minimum drawdown, maximum Sharpe ratio or a custom criterion coded into the EA.
The danger is simple. If you test enough combinations, some will look excellent on any data, including random data. The best of thousands is selected partly because it matched noise in that particular history.
Worked example: how fast the combinations add up
An EA has three inputs: a moving-average period tested from 10 to 200 in steps of 10 (20 values), a stop distance from 10 to 100 pips in steps of 5 (19 values), and a take-profit multiple from 1.0 to 3.0 in steps of 0.25 (9 values). That is 20 × 19 × 9 = 3,420 combinations.
Suppose (illustratively) that the true edge of every combination is zero. With 3,420 versions, random variation alone will produce some that look strongly positive over a few hundred trades. Picking the top one and calling it the strategy is like flipping 3,420 coins ten times each and declaring the coin that landed heads nine times a special coin.
Defences that work
- Use the forward period. Set Forward to 1/3 or 1/4, or a custom date. The tester optimises on the earlier part and then runs the chosen settings on the later part it did not see. The forward period does not prove anything on its own, but a large gap between in-sample and forward results is a clear warning.
- Look for plateaus, not peaks. If a moving-average period of 50 is excellent but 40 and 60 are poor, the result is fragile. If a broad range from 40 to 80 all perform reasonably, the idea may be real.
- Keep the parameter count small. Every extra input multiplies the search space and the opportunity to fit noise.
- Test across symbols and periods. A rule that works only on one pair, one timeframe and one year is a description of that history.
- Decide your acceptance rules before you look. Write down the minimum trade count, maximum drawdown and forward-period behaviour you will accept, then hold yourself to them.
Worked example: reading an in-sample and forward split
Illustrative figures for one optimised setting tested from the start of one year to the end of the following year, with the last third held back as the forward period:
- In-sample period: 310 trades, profit factor 1.62, maximum equity drawdown 9%.
- Forward period: 140 trades, profit factor 1.04, maximum equity drawdown 14%.
The forward period is not a disaster, but it is a very different strategy from the one the optimisation report advertised. Roughly breaking even before slippage, with higher drawdown, is the more realistic expectation. Most traders who see the in-sample numbers alone would size up; the forward numbers suggest the opposite.
Visual mode and debugging
Visual mode opens a chart and plays the test bar by bar, with the EA's trades and indicators drawn. Use it for a slice of the test, not the whole thing. Things to check:
- Entries happen where the rules say they should, on the bar you expect, not one bar early (a sign of the EA using the unfinished current bar) or one bar late.
- Stops and targets are placed at the intended distance and respect the broker's minimum stop level.
- Position size is what the risk rule says. Compare it with the position size calculator for the same stop distance and account balance.
- Trailing stops and partial closes behave as designed.
The Journal tab lists every order event and error. Errors such as invalid stops or not enough money in a test will also happen live, usually at the worst moment.
From the tester to a live account
A test that survives costs, real ticks, a forward period and sensible parameter ranges is a candidate, not a finished strategy. The next steps:
- Forward test on a demo account for long enough to see a meaningful number of trades. Our guide to moving from a demo account to live trading covers what a demo hides, such as fills and emotions.
- Compare live behaviour with the tester's over the same weeks. Run the tester on the forward-test period after the fact; differences show where the simulation diverges from reality.
- Start small with real money, at a risk per trade that keeps the worst-case drawdown survivable.
- Decide in advance what would make you switch it off, such as a drawdown deeper than the test's maximum by a set margin.
If the EA needs to run around the clock, it needs a terminal that stays on. Our guide to VPS hosting for forex trading covers when that is worth paying for.
Common mistakes
- Testing scalping or tight-stop EAs on generated ticks. The intrabar path is invented and the results can be wrong in a systematic direction.
- Ignoring zero commission in the report. Check the cost lines on every report.
- Running a short test. A few months and a few dozen trades say almost nothing.
- Optimising everything at once, then trading the single best result.
- Using an unrealistically large deposit. A large deposit hides the effect of minimum lot sizes and makes drawdowns look small in percentage terms.
- Treating the forward period as a second optimisation target. If you keep re-optimising until the forward period looks good, it is no longer out of sample.
- Trusting a seller's tester screenshot. Anyone can produce a beautiful curve with generated ticks, no costs and enough optimisation. Ask for real-tick settings, cost assumptions and the forward period, or better, a long live track record.
Frequently asked questions
Which modelling mode should I use in the MT5 Strategy Tester?
For final testing, "Every tick based on real ticks" whenever your broker provides the data. "Every tick" is acceptable for strategies with wide stops. "1 minute OHLC" and "Open prices only" are for fast screening, and "Open prices only" is only valid for EAs that act once per bar.
Why does my EA give different results with a different broker's data?
Because the prices, spreads and tick history are not the same. Brokers aggregate quotes from different liquidity sources and apply different markups. Small differences in spread or in which level was touched first add up over hundreds of trades.
Does the MT5 Strategy Tester include spread and commission?
Spread is always part of the test; in real-tick mode it is the recorded spread. Commission depends on how the symbol is set up on the broker's server, so check the commission line in the report and add it yourself if it is missing.
What does history quality mean in the report?
It shows how much of the test was run on real data rather than generated or filled-in data. In real-tick mode, a figure well below 100% means part of the period had missing ticks and the tester simulated them.
Can I test a manual strategy in the MT5 Strategy Tester?
Not directly; the tester runs code. You can code the rules as an EA, or use visual mode with a simple EA that lets you place trades by hand, but for most discretionary methods a manual bar-by-bar backtest with a written journal is more practical.
Is a good backtest enough to trade an EA live?
No. A good test is a reason to forward test on a demo, then trade small. Most retail CFD accounts lose money, and leverage magnifies losses whether the decisions come from a person or a program.
Not investment advice. This is general information and education, written without knowledge of your circumstances. It is not a recommendation to buy or sell any instrument. Past performance is not a reliable indicator of future results. Trading leveraged products carries a high risk of losing money. Risk warning