What is overfitting in trading?
Definition Overfitting, or curve fitting, is tuning a trading strategy so closely to past price data that it captures random noise instead of a repeatable pattern, so it looks strong in a backtest and weakens on new data.
Overfitting in trading means tuning a strategy so closely to past prices that it learns their noise, the random moves that will not repeat, instead of a pattern that might. The result looks excellent in a backtest and disappoints on new data, because it was fitted to a market that will not come back in the same shape.
How overfitting happens
Every input an EA has is a dial: an indicator period, a stop distance, a time filter. Turn enough dials on the same stretch of history and some combination will fit it well by chance.
MT5 makes the search easy. Optimisation in the Strategy Tester runs a strategy many times with different input sets, either every combination (“Slow complete algorithm”) or a genetic search that homes in on the best-scoring sets (“Fast genetic based algorithm”) (MT5 help). The tool is neutral; picking the top result from thousands of runs is where the fitting happens.
Worked example: counting the combinations
Warning signs
- Many inputs, few trades. Twelve settings tuned on 40 trades describe those 40 trades.
- Sharp peaks. The result collapses when one input moves a single step: a period of 23 works, 22 and 24 do not. Sturdier settings sit on a plateau where neighbours also work.
- Oddly specific rules. “No trades on Tuesdays”, added because Tuesdays lost in the test period.
- One market only. It works on one pair over one period and nowhere else.
- Frequent re-optimisation. Refitting after every losing month fits the newest noise.
How traders test for it
Out-of-sample data. Keep part of the history out of the search and test on it once. MT5 builds this in: the Forward setting reserves 1/2, 1/3, 1/4 or a custom part of the period, which MetaQuotes says checks optimisation results “in an effort to avoid overfitting in optimization time intervals” (MT5 help).
Forward testing on live prices. Freeze the settings and run them on a demo account; how to test an EA on a demo account sets out a 30-day plan.
Fewer dials. Fewer inputs leave less room to fit noise.
Why it matters for risk
An overfitted backtest understates the drawdown to expect, and position sizes chosen from it take more risk than they seem to. That raises the risk of ruin. The drawdown calculator shows how likely longer losing streaks are, and what a deeper drawdown takes to recover. Fitted results are also a common sales tool; how to spot a forex robot scam covers how they are presented.
Overfitting and PipWarden
PipWarden’s dashboard backtest has no optimiser. It replays the rule-based strategy with fixed indicator settings that are the same on every pair and that you cannot tune (currently the 50- and 200-period EMAs and a 14-period RSI and ADX), plus the risk settings you choose, on price history from your broker’s feed. Running many backtests and keeping whichever risk settings looked best is still a form of fitting, so the results describe the past, not what comes next. A demo account shows how the settings behave on prices they have never seen.
Frequently asked questions
Is optimisation the same as overfitting?
Does a demo account catch overfitting?
Educational content, not financial advice. Forex and CFDs are traded on margin and are high risk: you can lose money, and more than your deposit with some brokers. Examples use made-up numbers and show no real results. Read the risk disclosure.