Article · 2 min read
What Is Overfitting? Strategies That Fit the Past Too Well in Backtests
What overfitting is and how it inflates backtest results. The warning signs, common mistakes and ways to avoid overfitting while testing a strategy.
What is overfitting?
Overfitting is when a strategy learns the coincidences and noise in past data instead of a real pattern. It looks great in the historical test and then fails to deliver live. It is like memorising the answers to an exam instead of understanding the subject.
How does it happen?
- Trying too many settings: If you try hundreds of window lengths, thresholds and filters and pick the best-looking one, that result is often luck.
- Adding too many rules: Adding a new rule to block every bad trade produces a model that only fits the past.
- Too little data: A result from a small number of trades is statistically weak.
Warning signs
- Very high returns or a very smooth curve. Real strategies have bad periods too. See What is the Sharpe ratio?
- Extreme sensitivity to settings. If a small change in the window length wrecks the result, the strategy is not robust.
- Collapse on out-of-sample data. Good in the development period and bad afterwards is the classic sign.
How to avoid it
- Split the data: Divide it into development and test periods. Choose settings only on the development period and look at the test period once.
- Keep it simple: Rules with few parameters tend to be more robust.
- Add costs: Commissions and slippage weed out weak strategies. See Commissions and slippage in backtests.
- Validate in a virtual portfolio: Test forward with real prices. See the Backtesting and paper trading guide.
- Watch for survivorship bias: See Survivorship bias explained.
Remember
A backtest is a screen, not proof. The risk of overfitting depends less on how good the result is than on how many attempts it took to find it.
This article is educational and not investment advice. Past results do not guarantee future results; trading carries a risk of loss.