Backtesting
How to Backtest an EA in MT5 Properly: Strategy Tester Settings, Pitfalls and Validation
By Benjamin Lee · Updated · 9 min read
A backtest is a rehearsal, not a promise. Done well, it tells you how a strategy behaved across different market conditions and how bad the worst stretch was. Done badly, it produces a beautiful equity curve that collapses the week you go live. This guide covers every Strategy Tester setting that matters, the traps that inflate results, and a validation routine you can repeat on any EA.
Key takeaways
- Use Every tick based on real ticks for any EA that depends on intrabar timing, such as scalpers and tight-stop systems.
- Always include realistic spread, commission and execution delay, then stress them.
- Optimise on one period and validate on data the optimiser never saw.
- Judge a result by drawdown, trade count and stability, not by net profit alone.
- A smooth, near-perfect curve with few losing trades is a reason for suspicion, not celebration.
What a backtest can and cannot prove
A backtest replays historical prices through the EA's rules and records the trades it would have made. That is useful for three things: checking that the logic does what the author claims, measuring how large the losing periods were, and comparing parameter choices fairly.
It cannot prove the future. Markets change regime. Spreads widen. Your broker's execution is not the tester's. The honest goal of a backtest is to eliminate bad systems cheaply, not to certify a good one. A strategy that fails a careful backtest should not touch live money. A strategy that passes has only earned the right to the next stage, which is forward testing on demo.
Opening and configuring the MT5 Strategy Tester
Press Ctrl+R in MetaTrader 5 to open the Strategy Tester. Choose Single for one run (or Optimization for parameter sweeps), then select the EA, the symbol, the timeframe and the date range. Each choice affects the credibility of the result.
Step 1: Pick the EA and symbol
Use the exact symbol the EA was built for. Gold and indices behave very differently from major pairs, so a result on the wrong market is meaningless.
Step 2: Choose a long, varied period
Cover at least several years that include trends, ranges, high-volatility events and quiet months. A one-year window can sit entirely inside a single favourable regime.
Step 3: Select the modelling mode
This is the single most important setting. See the next section for what each mode actually simulates.
Step 4: Set the execution delay
Use a non-zero delay such as 50 to 200 ms, or the random delay option, rather than ideal execution.
Step 5: Set deposit, currency and leverage
Match your intended live account, since position size and margin use depend on it.
Step 6: Load the setfile
On the Inputs tab, load the vendor's .set file so you test the documented configuration rather than the defaults.
Choosing the right modelling mode
MT5 offers several ways to simulate price movement between candles. The faster ones are less precise, because they have to guess what happened inside each bar.
- Every tick based on real ticksHighest
Uses recorded tick history from the broker's server. Slowest, and the closest to live conditions.
- Every tickHigh
Generates synthetic ticks from 1-minute bars. Good, but the intrabar path is modelled, not recorded.
- 1 minute OHLCMedium
Uses only open, high, low and close of each minute. Fast but coarse for tight stops.
- Open prices onlyLow
Valid only for EAs that act at the bar open and never use intrabar stops.
Take a bar whose range contains both your take profit and your stop loss. With OHLC-only modelling the tester must assume an order of events. A scalper with a 5-pip target and a 6-pip stop will look different under each assumption, and none of them is the truth unless the actual ticks are replayed. This is why scalpers, breakout systems and anything with tight stops should be tested on real ticks.
Spread, commission, slippage and delay
Costs are where optimistic backtests fall apart. A strategy earning a thin edge per trade can lose all of it to a spread that is a few points wider than assumed. Always model costs the way your live broker charges them.
| Cost | How to model it in MT5 | Stress test |
|---|---|---|
| Spread | Real ticks include the broker's actual bid and ask. Otherwise set a realistic fixed spread. | Add 20 to 50% to the spread and see if the edge survives. |
| Commission | Define it on the custom symbol or deduct per lot in your analysis. | Test the account type with the highest commission you might use. |
| Slippage | Use the execution delay setting and the random delay option. | Double the delay and re-run. |
| Swap | Included from the symbol's specification. | Check long-held basket or grid trades separately. |
| Rollover and news widening | Present only if the data contains it. | Inspect results around 22:00 to 23:00 server time and major releases. |
A useful habit is to run the same test three times: base case, then with 30% higher costs, then with doubled delay. A robust system degrades gracefully. A fragile one flips from profit to loss, which tells you the edge was smaller than the friction all along.
Reading the report: the numbers that matter
The report lists dozens of figures. Focus on a short list and read them together, because any single metric can be flattering on its own.
| Metric | What it tells you | Rule of thumb |
|---|---|---|
| Equity drawdown (max) | The deepest peak-to-trough fall of equity, including floating loss | Prefer equity drawdown over balance drawdown. Grid systems hide pain in floating losses. |
| Profit factor | Gross profit divided by gross loss | Roughly 1.3 to 2 is realistic. Very high values on few trades are suspect. |
| Recovery factor | Net profit divided by max drawdown | Higher is better, but verify across sub-periods. |
| Total trades | Sample size | Several hundred or more before trusting averages. |
| Expected payoff | Average profit per trade after costs | Must comfortably exceed your real trading costs. |
| Largest losing trade and consecutive losses | Tail risk | Compare the loss streak with your own risk limit. |
| Sharpe ratio | Return relative to volatility | Use to compare similar systems, not as a standalone grade. |
- Martingale
- Grid
- Trend
- Scalper
Optimisation without fooling yourself
MT5 can sweep parameters automatically, using the Slow complete algorithm for small searches or the Fast genetic algorithm for large ones, and can distribute the work across your cores or the MQL5 Cloud Network. The danger is overfitting: with enough combinations, some will fit past noise perfectly and have no predictive value.
- Optimise few parameters. Each extra free input multiplies the chance of a lucky fit.
- Look for plateaus, not peaks. Choose a value whose neighbours also perform well. A lone spike is usually noise.
- Use the forward option. MT5 lets you reserve the last portion of the period (for example one third) as an out-of-sample window that the optimiser never trains on.
- Prefer a custom criterion. Optimising for net profit alone rewards risk. Criteria that balance profit and drawdown give steadier answers.
A validation routine that catches most bad EAs
After a promising run, do not stop. Use the sequence below. Each stage is designed to break strategies that are lucky rather than sound.
Walk-forward analysis extends this idea: optimise on a window, test on the next unseen window, slide forward, and repeat. If performance holds across many unseen windows, the edge is more likely real. A basic Monte Carlo check, which reshuffles trade order or randomly skips trades, shows how bad a sequence of losses could be even with the same average results. MT5 does not include Monte Carlo natively, but you can export the trade list and run it in a spreadsheet or a short script.
Red flags in any backtest, including vendors'
- A near-straight equity line with tiny or invisible drawdowns. Real strategies lose. A curve this smooth often hides martingale or unclosed floating losses.
- Tested only on 1-minute OHLC or open prices for a scalping or breakout EA.
- No spread or delay stated. If the report omits costs, assume they were zero.
- Short history. Two or three months can sit entirely inside one friendly trend.
- Huge lot sizes relative to deposit that make percentage gains look large but expose the account to ruin.
- Balance curve shown, equity curve hidden. Floating drawdown is where the danger lives.
- Cherry-picked symbols or periods with no results across the broader sample.
From backtest to forward test
A backtest runs on history that already exists, and forward testing runs on prices as they arrive. Put the validated EA on a demo account for several weeks and log every trade. Compare the live statistics with the backtest: win rate, average trade, trade frequency and drawdown. Small differences are expected, since fills and spreads vary. Large, persistent ones mean the model of the market, or the data, is wrong, and it is far cheaper to find that out on demo.
Once the numbers agree, follow the staged approach in our EA installation and risk guide: small live size first, scale slowly, review weekly.
Frequently asked questions
Which MT5 tester mode should I use?
Use Every tick based on real ticks whenever the EA uses tight stops, scalping, or intrabar logic. Open prices only is acceptable only for systems that act exclusively at the bar open and never rely on intrabar stops.
Why does my backtest not match the vendor's report?
Common causes are different tick data, different spreads or commission, a different date range, a different symbol suffix, or a different setfile. Align those inputs first, then compare again.
How many years of data do I need?
Enough to cover several different market regimes, typically three to five years or more, and with several hundred trades. The exact length depends on how often the strategy trades.
What is overfitting, and how do I avoid it?
Overfitting is tuning parameters so tightly to past data that they capture noise. Reduce the number of optimised inputs, choose stable plateaus, and validate on data the optimiser did not see.
Is a high profit factor always good?
No. A very high profit factor on a small number of trades is often luck or hidden risk. Check the sample size, the equity drawdown, and whether the result holds under higher costs.
Expert Advisors in these styles
Apply the checks above to any of these before you buy: read the manual, run your own backtest, and start on demo.
Keep reading
- BacktestingHow to Read an MT5 Backtest ReportLearn to read an MT5 Strategy Tester report line by line: drawdown, profit factor, Z-score, trade quality, robustness checks and the red flags that expose a weak EA.
- Data qualityHistorical Tick Data for MT5 BacktestsCompare sources of forex and gold tick data for MT5: broker real ticks, Dukascopy, Tickstory and paid vendors. Learn to clean, import and verify data quality.
- EA basicsHow to Install and Run an EA on MT5Install an Expert Advisor on MetaTrader 5, load a setfile, set safe risk limits, and run it on a VPS. A practical walkthrough with a pre-live checklist.


