How to avoid over-fitting when you optimise an EA
Why the best optimisation result is usually the worst one to trade, and how forward tests, parameter neighbourhoods and Monte Carlo analysis help you pick robust EA settings.
Updated 5 November 2026
Run enough combinations of inputs and one will always look brilliant. That’s the trap: with 5,000 combinations, the best one is usually the luckiest, not the best. Here is a practical routine to pick settings that have a chance on new data.
1. Optimise fewer things
Every input you optimise multiplies the chances of a lucky fit. Optimise the two or three inputs that define the idea (for example the range length and the stop), and keep the rest at sensible fixed values. Prefer coarse steps: a stop of 20, 30, 40 pips rather than every pip from 15 to 45.
2. Keep a forward period aside
In QuantForge’s Optimise tab (Studio), set a forward test share such as 25%. The grid runs only on the earlier part of your dates. The ten best combinations are then re-tested on the last part, which they never saw.
Read the forward column first. A combination that earned a profit factor of 2.1 in-sample and 0.9 forward was fitted to noise. One that scored 1.4 and then 1.3 is more interesting.
3. Look at the neighbourhood
A robust setting has good neighbours: if a 30-pip stop works, 25 and 35 should work too, only a little worse. If the profit collapses one step away, the peak was luck. Sort the results and check the rows around your candidate before picking it.
4. Require enough trades
Set Min. trades so that combinations with a handful of trades sort last. Twenty trades can produce almost any profit factor by chance; a few hundred tell you much more.
5. Stress-test the trades
Run the chosen combination as a normal backtest, then open the Monte Carlo tab:
- Shuffle keeps the same trades in random order: the final profit stays the same, but the drawdown changes. If the 95th percentile drawdown is twice your backtest’s, plan your risk for that.
- Resample draws trades with replacement, so you see a range of outcomes from a similar strategy.
- Skip trades drops a share of trades at random, like missed fills or downtime.
Look at the chance of a loss and of reaching your ruin level. If either is uncomfortable, reduce the risk per trade before anything else.
6. Confirm out of sample, then on demo
Finally, check the strategy on another symbol or period it was never tuned on, repeat the run in MetaTrader with the exported tester settings, and trade it on a demo account. Only what survives all of that deserves real money, and even then, with small risk at first.
More: Studio features and backtesting on your broker’s data.
Frequently asked questions
What is over-fitting?
Over-fitting is tuning a strategy so closely to past data that it captures noise instead of a real pattern. It looks excellent in the backtest and fails on new data.
How much data should I keep for the forward test?
Commonly 20% to 30% of the period, at the end. It must be data the optimisation never saw, and you should look at it only after choosing your candidates.
Does Monte Carlo analysis prove a strategy works?
No. It shows how much the results depended on luck in the order or selection of the same trades. It can't tell you whether those trades will happen again.
Build your first EA today
The free plan includes three projects, backtests on H1 to D1 over a year, MQL4/MQL5 export and the converter.