Overfitting
Overfitting is tuning a strategy so closely to past data that it captures noise rather than a real pattern, so it fails on new data.
Tweak enough settings and almost any strategy can look brilliant on last year's chart. The trouble is that the market won't repeat last year's noise. Overfitting is the gap between a perfect backtest and a disappointing live account.
- Reading time
- 3 min
- Also called
- Curve fitting, Over-optimisation
- Updated
Overfitting in plain words
In machine learning, a model is overfitted when it fits its training data so closely it can't make accurate predictions on any other data.1
Trading strategies suffer from the same problem: tuned to look great on past data, they then fail when market conditions change.2
The cause is learning the 'noise' — irrelevant information — in the data.1
How to guard against overfitting
Fix rules first
Document all parameters before you begin the backtest.2
Hold data back
Set aside part of the data as a test set to check for overfitting.1
Compare in and out of sample
Low error on training data but high error on test data signals overfitting.1
Keep it simple
Reduce complexity by eliminating less relevant inputs.1
Test many conditions
Backtest across different time periods and market conditions.2
Cross-validate
Use techniques such as k-fold cross-validation to check accuracy.1
Worked examples
Example 1 — Too many knobs
Edge disappears out of sampleA hypothetical strategy is tuned with 9 parameters on 2 years of data and shows a +60% backtest; on the next year it returns −8%.
| In-sample | +60% |
| Out-of-sample | −8% |
Strong results on training data with poor results on new data signal overfitting.1
Example 2 — The magic moving average
Likely luck, not edgeA hypothetical trader tests every moving-average length from 5 to 200 and picks 37 because it scored best.
| Lengths tested | 196 |
| Chosen | 37 (best in-sample) |
Picking the single best setting risks fitting the noise in that particular data set.1
Example 3 — A simpler, robust version
Results hold up on new dataThe same hypothetical strategy reduced to 2 parameters returns +18% in-sample and +11% out-of-sample.
| In-sample | +18% |
| Out-of-sample | +11% |
Reducing complexity by removing less relevant inputs gave a smaller but more believable result.1
Overfitted vs robust strategy
| Aspect | Overfitted | Robust |
|---|---|---|
| Parameters | Many, finely tuned | Few, simple |
| Backtest | Spectacular | Good, not perfect |
| Out-of-sample | Breaks down | Similar to backtest |
| Sensitivity to settings | High | Low |
Where overfitting matters
Backtesting
Checking Backtesting results on unseen data.
Indicator settings
Avoiding over-tuned Moving Average or Relative Strength Index lengths.
Automated systems
Validating rules before running them live.
Performance claims
Questioning a perfect equity curve or Sharpe Ratio.
Advantages and disadvantages
Advantages
- Recognising it prevents false confidence.
- Out-of-sample tests are cheap to run.
- Simpler strategies are easier to follow.
Disadvantages
- Hard to detect from a single backtest.
- Tempting because results look great.
- Holding data back reduces data for testing.
- Even robust tests can't guarantee the future.
Going deeper
Read as far as you need. Each level builds on the one before it.
Learning the noise
Beginner
A model that fits training data too closely can't predict anything else.1
Test what you didn't tune
Intermediate
Set aside a test set and compare: low training error with high test error signals overfitting.1
Robustness over perfection
Advanced
Strategies fine-tuned to past data can fail in new conditions, so test across varied periods and remember backtests assume perfect execution.2
Common mistakes
Optimising everything
Adding filters until every loser disappears.
Peeking at the test set
Retuning after seeing out-of-sample results.
One market, one period
Testing only a single trending stretch.
Ignoring costs
Leaving out slippage and fees that erase thin edges.
Check your understanding
Test yourself before moving on. Each answer comes with an explanation.
Key points to remember
- Overfitting captures noise, not edge.
- Perfect backtests are a warning sign.
- Always test on data you didn't tune on.
- Fewer parameters are usually more robust.
- Test across varied market conditions.
Frequently asked questions
Is optimisation always overfitting?
What is walk-forward testing?
How much data should I hold back?
Further learning
- Backtesting
How to test strategies properly.
- Trading Edge
What a real edge looks like.
- Expectancy
Measuring results that last.
- Sharpe Ratio
Judging risk-adjusted results.
Sources
This article is written in our own words. The sources below support the specific facts, rules and figures marked with a number in the text. Links open the original publisher’s page.
- IBM. What is Overfitting? (opens in a new tab) Checked .
- CMC Markets. Backtesting trading strategies (opens in a new tab) Checked .
Educational content, not financial advice. Examples use hypothetical prices and simplified costs; actual fees, margin rules and regulations vary by broker, market and country. We are not affiliated with any publisher linked above. Last reviewed . Report an error or request a source credit.