Out-of-sample and walk-forward testing in MT5, step by step
Optimising an EA on the same data you test it on guarantees a pretty result and proves nothing. Here's how to use out-of-sample and forward testing in the MT5 Strategy Tester.
The problem with optimisation
Give an optimiser enough inputs and enough data, and it will find settings that fit the past perfectly, including its noise. Those settings usually fail on data they haven't seen. The fix is simple: keep some data the optimiser never touches.
Built-in forward testing
In the Strategy Tester, set Forward to 1/2, 1/3 or 1/4 (or a custom date). MT5 optimises on the first part and automatically re-runs the best results on the forward part. Sort by the forward results: settings that hold up on both parts are the interesting ones.
Manual walk-forward
- Optimise on year 1 with as few inputs as possible (3 or fewer is a good discipline).
- Freeze the preset and test it on year 2 without changes.
- Roll forward: optimise on year 2, test on year 3.
- Look at the chain of out-of-sample results, not at the best in-sample one.
What good looks like
Out-of-sample results will almost always be weaker than in-sample. That's normal. What you're looking for is similar behaviour: comparable drawdown, trade frequency and win rate. A system that collapses out of sample was fitted to noise.
Questions
- How much data should I hold back?
- A common choice is 25–33% of the period, and at least enough for a few hundred trades.
- Is walk-forward the same as live testing?
- No. It's still historical. A demo or small live account running alongside is the next step.
Put it into practice. Algo Dispensary drops VERUM-screened MT5 EAs every weekday and runs a weekly testing challenge. Members get Vidette, our equity-guard EA, free.
Join Algo DispensaryBrowse the algosMore guides
- How to backtest an MT5 EA on real ticks (and why your results will change)
- What is a .set file in MT5? Loading, saving and versioning EA presets
- How to spot a martingale or grid EA before it spots your account
- Running an EA on a prop-firm challenge: the rules to code in, not remember
- Spread and news filters: the two EA inputs that save scalpers