Learn › Strategy testing

Backtesting Pitfalls: Look-Ahead Bias, Overfitting and Unrealistic Fills

A backtest runs trading rules over historical data to see how they would have behaved. Done well, it is the cheapest way to discard bad ideas. Done badly, it produces beautiful equity curves that collapse the moment real money is involved. Almost every gap between backtest and live results comes from a short list of well-known mistakes.

1. Look-ahead bias

Look-ahead bias means the test uses information that would not have been available at the moment of the decision. Common forms:

  • Using the current bar's close to enter on the same bar's open. If a signal is computed from a bar's close, the earliest realistic entry is the next bar's open, or the close itself only if your execution can actually act at that instant.
  • Using the bar's high or low before the bar is complete. An intrabar rule that "buys if price breaks the high" must not know the bar's final high in advance.
  • Repainting indicators. Some indicators revise past values when new data arrives, such as certain pivot and zig-zag calculations. A backtest on the revised values sees signals that were never visible in real time.
  • Adjusted data. Split- and dividend-adjusted prices are correct for return calculations but do not match the prices you could actually have traded at.

2. Overfitting

Overfitting is tuning a strategy so precisely to past data that it captures noise rather than a repeatable pattern. Warning signs:

  • Many parameters relative to the number of trades.
  • Performance that collapses when a parameter is changed slightly (for example, a moving average of 21 works but 20 and 22 lose money).
  • Rules that seem oddly specific, such as "only on Tuesdays when RSI is between 37 and 41".
  • Very high win rates or profit factors on a small sample.

The defences are simplicity, a large number of trades, parameter stability (look for broad plateaus of good results rather than isolated peaks) and testing on data the rules were not tuned on — the idea behind walk-forward optimization.

3. Unrealistic fills and costs

  • Costs. Brokerage, exchange fees, taxes and, for derivatives, funding all reduce returns. High-frequency strategies with small average profits are the most sensitive.
  • Slippage. Market and stop orders fill at the next available price. Assume some slippage per trade, more for illiquid instruments and fast markets.
  • Limit order fills. A backtest that assumes a limit order fills whenever price touches the limit is optimistic; in reality you may be behind other orders in the queue.
  • Intrabar ambiguity. If a bar's range covers both the stop and the target, the data alone cannot tell which was hit first. Conservative tests assume the stop.

4. Survivorship and selection bias

Testing a stock strategy only on today's index members ignores companies that were removed after collapsing. Choosing to test only the instruments that trended strongly last year is a related bias. Use point-in-time universes where possible and decide the test universe before seeing the results.

5. Data quality and session mismatches

Missing bars, bad ticks and timezone errors silently change indicator values. Session definitions matter too: a daily bar built from 24-hour data is different from one built from regular trading hours. Make sure the backtest's data source, timeframe and session rules match what the live system will use.

6. Ignoring the path

Total return hides the experience of trading the strategy. Look at maximum drawdown, the longest time spent below a previous equity high, the longest losing streak and the distribution of monthly returns. A strategy whose total return looks attractive but which spends two years in drawdown is unlikely to be followed in practice.

A practical checklist

  1. Signals use only completed data; entries happen no earlier than the next actionable price.
  2. Costs and slippage are included and are on the pessimistic side.
  3. Results are reasonably stable across nearby parameter values.
  4. There are enough trades to mean something — dozens at minimum, ideally hundreds.
  5. Out-of-sample or walk-forward results are reviewed, not just the optimised period.
  6. Drawdown and losing streaks are acceptable at the intended position size.
  7. The strategy is run on a paper account and the paper results are compared with the backtest before risking capital.

Key takeaways

  • Most backtest disappointments come from look-ahead bias, overfitting and optimistic fills.
  • Prefer simple rules with stable parameters and many trades.
  • Historical results never guarantee future performance; treat a backtest as a filter, not a forecast.

Educational content only. This guide explains general concepts and is not investment advice or a recommendation to trade any instrument. Trading involves substantial risk of loss, and historical or simulated results do not guarantee future performance. Read the Risk Disclosure.

Related guides