How to backtest an EA properly in MT5: 7 checks before you trust it
A backtest that looks great proves very little on its own. These are the checks that separate a strategy that holds up from one that was fitted to the past, all of them doable in the MetaTrader 5 Strategy Tester.
Set up the test so it means something
- Modelling: Every tick based on real ticks. The other modes invent the price path inside each bar, and EAs with tight stops or targets look better than they are. Check the history quality in the report.
- Your broker's symbol and costs. Spread, commission and swap change the result, and much more on scalpers. Test with a realistic spread, not the narrowest of the day.
- A long period. Several years, with different markets in it: trends, ranges, high and low volatility.
- The risk you will really use. A test at 5% per trade says nothing about running it at 0.5%, and the other way round.
The 7 checks
- Enough trades. Thirty trades can be luck. A few hundred start to say something about the edge.
- Year by year. Look at each year separately. One huge year that pays for four flat or losing ones is a fragile strategy.
- Data it has never seen. Choose the settings on one part of the history and test them on a later part that was left out. If the result collapses there, the settings were fitted to noise.
- Nudge the settings. Move each input a little up and down. A strategy that only works with a period of exactly 47 is not a strategy.
- Double the costs. Run it again with twice the spread or commission. If the profit disappears, the edge is too thin for real trading.
- Profit factor and drawdown, not win rate. A 90% win rate with rare, huge losses is a typical way to lose an account. Look at net profit against maximum drawdown.
- Without the best trades. Remove the top few percent of the trades. If nothing is left, the result depends on a handful of lucky hits.
The full checklist, free
The EA Reality Check: 12 tests to run before you trust an Expert Advisor with real money, with a score sheet. PDF, free.
Optimizing without fooling yourself
The optimizer of the Strategy Tester will always find a combination that made money in the past. Sorted by profit, it rewards exactly the combinations that fitted the past best, which are usually the ones that fail first. Three habits help:
- Keep the last part of the history out of the optimization, and only look at it once, at the end.
- Prefer a plateau to a peak: a zone of settings that all work reasonably well beats one setting that works brilliantly.
- Optimize for robustness, not profit. MT5 lets an EA return its own score as the Custom max criterion, so the optimizer can rank by steadiness, drawdown, years in profit and the result on the recent period instead of raw profit.
That last idea is how Breakout Lab MT5 works: its robustness score weighs the recent part of the test more, scores 0 if the strategy breaks down there, and penalizes results that depend on a few trades.
Reading the report
- Maximum equity drawdown, not only balance drawdown: equity includes the open losses.
- Maximum consecutive losses: can you live through that streak without switching it off?
- Recovery factor: net profit divided by maximum drawdown. The higher, the more the profit pays for the pain.
- The curve: steady growth with shallow dips, not a flat line followed by one jump.
And always remember what a backtest is: a hypothetical result on past data. It does not guarantee future performance, and the real test starts on a demo account.
Questions
Which modelling should I use in the MT5 Strategy Tester?
Every tick based on real ticks. The other modes generate the price inside each bar and make EAs with tight stops or targets look better than they are.
How many trades does a backtest need?
There is no magic number, but a few hundred trades over several years say much more than thirty. Fewer trades means more of the result can be luck.
What is out-of-sample testing?
Choosing the settings on one part of the history and then testing them, unchanged, on a later part that was left out. If the strategy only works where it was optimized, it was fitted to the past.
Is a high win rate a good sign?
Not on its own. Look at profit factor, net profit against maximum drawdown and the longest losing streak. A high win rate with rare, large losses is a common way to lose an account.
Does a good backtest guarantee live results?
No. A backtest is a hypothetical result on past data. Run the EA on a demo account and compare it with the backtest before trading it with real money.
