Guide · Backtest
Backtest overfitting: when the results look too good
A curve that climbs with no drawdowns for ten years looks like the perfect strategy. Often it's just fitted to the past. Here's how to spot it before you lose money on it.
What it is
Overfitting means tuning the inputs until they match the noise of a specific period, not a pattern that repeats. On historical data, the result is spectacular. In the future, that noise will be different.
In sample, out of sample
The classic defense is to split the history into sections. The strategy is designed on the first one (in sample). The second (out of sample) is held out: the strategy has never seen it.
If the result drops sharply in the held-out period, much of the backtest was curve fitting. When it stays similar, there's more reason to trust it.
One important caveat: as soon as you change the strategy based on what you saw in the held-out period, it no longer works as a test.
Warning signs
- An almost perfect curve, with hardly any drawdown.
- Many inputs tuned to the decimal.
- Few trades for so many settings.
- A result that collapses when you shift any value slightly.
- It only works on one symbol or over very specific dates.
The ultimate test is live trading
No test on historical data replaces watching the robot trade on new data. That's why it pays to incubate it on demo. Then compare its result with the backtest over the same dates.
A simple example
You take a moving average crossover that barely makes money. You test a thousand combinations of periods, hours, filters.
Some will produce a beautiful curve by pure chance. If you keep that one, you've picked the one that best fitted the noise of those years.
Tests that help detect it
- Stable neighbors: change each input slightly. A healthy system keeps winning with nearby values.
- Other markets: run it on a similar symbol. It doesn't need to shine, just not collapse.
- Higher costs: raise the spread in the simulation. Real edges survive a bigger toll.
- Walk-forward: optimize on one section to test on the next, several times in a row.
- Monte Carlo: shuffle the order of the trades or skip some. That way you see how much the drawdown changes.
How to reduce it when building a strategy
- Few rules, with logic you can explain.
- Many years of data, including difficult periods.
- A held-out period you don't touch until the end.
- Hundreds of trades for every input you tune, not dozens.
What no test guarantees
Passing all these tests reduces the risk without eliminating it. The market can change even if the design was clean.
That's why the next step is to incubate the robot until it gathers a large enough sample before giving it money.
Frequently asked questions
What is overfitting in trading?
Overfitting is tuning a system's inputs so closely that it ends up fitting the noise of the past. The backtest looks brilliant, but it doesn't repeat on new data.
What's the difference between in sample and out of sample?
The in sample period is used to design the strategy. The out of sample period is held out: it's used to test the strategy on data it has never seen.
How do I know if my backtest is overfitted?
Be wary of a curve with no drawdowns, with many inputs tuned to the decimal. Another clue: the result collapses when you shift any value slightly.