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.

Category
Trading Psychology and Performance
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

  1. Fix rules first

    Document all parameters before you begin the backtest.2

  2. Hold data back

    Set aside part of the data as a test set to check for overfitting.1

  3. Compare in and out of sample

    Low error on training data but high error on test data signals overfitting.1

  4. Keep it simple

    Reduce complexity by eliminating less relevant inputs.1

  5. Test many conditions

    Backtest across different time periods and market conditions.2

  6. 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 sample

A hypothetical strategy is tuned with 9 parameters on 2 years of data and shows a +60% backtest; on the next year it returns −8%.

Example 1 — Too many knobs — calculation
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 edge

A hypothetical trader tests every moving-average length from 5 to 200 and picks 37 because it scored best.

Example 2 — The magic moving average — calculation
Lengths tested196
Chosen37 (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 data

The same hypothetical strategy reduced to 2 parameters returns +18% in-sample and +11% out-of-sample.

Example 3 — A simpler, robust version — calculation
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

AspectOverfittedRobust
ParametersMany, finely tunedFew, simple
BacktestSpectacularGood, not perfect
Out-of-sampleBreaks downSimilar to backtest
Sensitivity to settingsHighLow

Where overfitting matters

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

  1. Optimising everything

    Adding filters until every loser disappears.

  2. Peeking at the test set

    Retuning after seeing out-of-sample results.

  3. One market, one period

    Testing only a single trending stretch.

  4. 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.

Q1In-sample +40%, out-of-sample −5%. Most likely?
Q2Which helps prevent overfitting?

Key points to remember

  1. Overfitting captures noise, not edge.
  2. Perfect backtests are a warning sign.
  3. Always test on data you didn't tune on.
  4. Fewer parameters are usually more robust.
  5. Test across varied market conditions.

Frequently asked questions

Is optimisation always overfitting?

No. Light optimisation is fine if results hold on unseen data.

What is walk-forward testing?

Repeatedly tuning on one window and testing on the next, to mimic live trading.

How much data should I hold back?

Many traders reserve roughly 20–30% of the history as untouched test data.

Further learning

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.

  1. IBM. What is Overfitting? (opens in a new tab) Checked .
  2. 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.