MT5 overfitting: what it is and how to spot it before you risk money
You optimize your EA, pick the best pass, and live it looks nothing like the backtest. The cause is almost always the same: the parameters fitted the noise of the past, not something that repeats. This is how you recognize it.
What overfitting is
When the Strategy Tester tries thousands of parameter combinations, some always come out brilliant. Part of that shine may be real, but part is chance: the combination happens to fit specific moves in that price history that will not repeat. Overfitting (also called curve fitting) is picking exactly that combination. The more you try, the more likely it is that the best one is mostly luck.
Sign 1: isolated peaks
Look at the neighbors of the best pass: the ones that change a single parameter by one step (from 30 to 35, from 0.1 to 0.2). If the best one has a profit factor of 2 and its neighbors are around 1, you have not found a good zone, you have found a peak. The market never behaves exactly as in the backtest, and a peak leaves no margin. What you want is a plateau: a zone where many nearby combinations work, and to stay in its center.
Sign 2: the forward collapses
With Forward enabled, MT5 tests the best passes on a stretch it did not use to optimize. Some decline is normal; what gives overfitting away is the top in-sample passes sinking in the forward, or the ranking changing completely. One caution: do not simply pick the pass with the best forward. Then the forward stops being a clean test and becomes just another optimization.
Sign 3: too many trials for too little data
Every parameter you optimize and every value you add to a range multiplies the combinations. With many trials and few trades, chance alone can produce spectacular results. It can be measured: compute the Sharpe ratio you would expect from the best pass by pure luck, given how many combinations were tested, and check whether yours beats it. If it does not, your best result may be nothing but noise.
Sign 4: only the Result column shines
MT5 sorts by the criterion you asked it to optimize, so the top row is the one that benefited most from chance in that criterion. Look at several metrics at once: profit factor, drawdown, recovery factor, number of trades. A solid configuration is reasonable in all of them; an overfitted one usually stands out in one and falls short in the rest.
How to reduce it
- Optimize fewer parameters, with sensible ranges: only the ones that really change how the EA behaves.
- Always enable Forward, and keep a final stretch untouched for the last test.
- Set minimums before sorting: the profit factor, drawdown and number of trades you would accept live.
- Pick the center of a plateau, not the top row.
- Test the chosen configuration with somewhat worse spread or slippage than in the backtest.
Next step
Orometra runs these checks for you on the XML of your optimization: it looks for plateaus, checks them against the forward, measures how much could be luck and tells you how much evidence backs a configuration. Everything runs in your browser: your files never leave your computer.