GUIDE

Overfitting in backtesting: how to spot it

Testing a strategy · 5 min read

Overfitting is what happens when a strategy is tuned so closely to past prices that it has learned their noise rather than anything lasting. The result looks excellent, and it is the most common way a backtest misleads.

Why it happens

Every stretch of price history contains patterns that happened by chance. Try enough settings and one of them will line up with those accidents. Nothing is wrong with the test: the settings really would have done that, on those prices. It simply says little about any other prices.

The more you try, the stronger this gets. Search a thousand combinations and the top one will look exceptional even on random data, so a high score on its own proves almost nothing once you have searched for it.

The warning signs

  • A spike, not a plateau. A 50-period EMA looks great, but 45 and 55 look poor. Real behaviour rarely depends on one exact number.
  • Too many conditions. Each extra rule lets the strategy fit history more tightly and leaves fewer trades.
  • Few trades. A strong result on a small count is easy to produce by chance.
  • Settings with no reason behind them. If you cannot explain why RSI 37 and not 30 or 40, the history probably chose it.
  • It only works on one market. Rules that fall apart on similar markets may have fitted that one.

How to check

Look at the neighbours. A parameter search runs every combination of up to three settings and draws a map. A broad area of similar results is more reassuring than one bright cell. This guide shows how to read one.

Test other history. Tune on one stretch and then run the settings on a stretch they have never seen. If the behaviour disappears, the tuning was probably fitting noise.

Test other markets. Run the same rules on similar instruments. You are not looking for identical results, only for the same character.

Keep it simple. When two versions behave similarly, prefer the one with fewer conditions.

Look at the range. The Monte Carlo simulator shows how much drawdowns and losing streaks can vary, even when nothing about the strategy changes.

Search tools make this more important

A tool like Refine tries many variations of a strategy, which is powerful and is also exactly how overfitting happens. Treat what it finds as a hypothesis to check on data it has not seen, never as a finished strategy.

What no check can do

None of these checks proves a strategy will work. They only remove some of the ways it might be fooling you. Backtested results do not indicate future results.

Try this in SixOne8

Build a strategy and test it on years of real prices. Free to start, no card.

Next