Risk Management & StatisticsIntermediate

Look-Ahead Bias and Overfitting

What overfitting, look-ahead bias, data snooping and survivorship bias are, why tuned backtests fail on new data, and how out-of-sample testing exposes them.

Library categories

What it means

Overfitting is tuning a rule until it matches past data so closely that it fails on new data. Look-ahead bias is using information in a test that would not have been known at the time, such as a candle's close before it closed or a swing that was only confirmed later.

Related problems: data snooping (testing many ideas and keeping the best) and survivorship bias (testing only assets that still exist).

Why traders use it

Both make backtests look better than live results. The cure is to keep some data unseen until the rules are fixed, and to make the code only use closed candles and confirmed pivots.

Chart examples

Tuned on the past, tested on unseen data

Tuned periodUnseen periodIn-sampleOut-of-sample
A schematic equity curve: smooth on the data used to tune it, then falling on data it has not seen.Schematic diagrams drawn to explain the idea; they are not market data.

How to identify it objectively

  • 1Split data: in-sample for development, out-of-sample for one final test.
  • 2Count how many variations you tried.
  • 3Check every input is available at the decision time.
  • 4Watch for performance that collapses on new data.

Bullish use

  • 1A rule that performs similarly in and out of sample is more credible.
  • 2Few parameters and simple rules overfit less.

Bearish use

  • 1A smooth in-sample curve followed by an out-of-sample decline is the classic overfitting signature.

What confirms it

  • Walk-forward results across several periods.
  • Similar results on related markets.

What invalidates it

  • Rules changed after seeing out-of-sample results.
  • Indicators that repaint.

How a hypothetical setup is built

Entry

Fix every rule before the out-of-sample test.

Stop

Use only closed-candle data in the test.

Target

Report in-sample and out-of-sample results separately.

A hypothetical illustration of how the concept is turned into a plan, not a recommendation. Practise it on a paper account first.

Historical testing

The diagram is schematic: a curve tuned on the first period and then run on unseen data. It shows the pattern to look for, not a result.

Limitations: when it fails

  • Even out-of-sample tests can be overfitted if repeated many times.
  • Markets change, so past robustness is not a guarantee.
  • Small samples hide bias.

Knowledge check

Pick an answer to see the explanation. Nothing is saved.

Using a swing high before it was confirmed in a backtest is…

1. Using a swing high before it was confirmed in a backtest is…

A strategy great in-sample but poor out-of-sample is probably…

2. A strategy great in-sample but poor out-of-sample is probably…

Testing 200 settings and keeping the best is…

3. Testing 200 settings and keeping the best is…

Practise it risk-free

Open the free chart, use replay to go back in time and look for this concept candle by candle with $20,000 in virtual money.