In questa pagina
If you have ever built a strategy with a flawless backtest that fell apart the instant you traded it, you have met overfitting. It is not bad luck and it is not a rare edge case. It is the default outcome of strategy development, and learning to recognise and prevent it is most of what separates a profitable quant from a frustrated one.
What overfitting actually is
Any stretch of market history contains two things mixed together: signal — real, repeatable structure — and noise — random wiggles that will never occur in that exact shape again. A strategy is overfit when its rules have, knowingly or not, been shaped to match the noise. It scores brilliantly on the data it was built on, because it has effectively memorised that data's accidents. On any other data — including the future — those accidents do not repeat, and the strategy has nothing left.
The classic analogy: a student who memorises the answers to last year's exam paper looks like a genius until they sit this year's paper. Overfitting is memorising the answers. Real edge is understanding the subject.
How it creeps in — usually invisibly
- Too many parameters — every knob you add is another degree of freedom the optimizer can use to bend the strategy around the noise. A rule with eight tunable numbers can fit almost any past.
- Too much searching — sweeping parameters and keeping the best result is, by construction, selecting for the luckiest fit. The more combinations you try, the more overfit the winner.
- Tweaking until it works — adding a filter, then another, each time the backtest dips, is overfitting done by hand. You are still fitting to the noise, just manually.
- Reusing the same data — if you test, adjust, and re-test on one dataset, that data has leaked into every decision and can no longer judge the strategy honestly.
The warning signs
Beyond a suspiciously perfect curve, watch for fragility. If changing a parameter by one notch — RSI period 14 to 13 — collapses the result, you have not found a robust level, you have found a single lucky value. If the strategy makes most of its money in a tiny handful of trades, the rest being flat, it is not a system, it is a few coincidences. If it works beautifully on one symbol and fails on similar ones, the same conclusion. Robust edges degrade gracefully; overfit ones fall off a cliff.
How to prevent it
- Keep it simple — fewer rules, fewer parameters. Every knob you remove is a way the strategy can no longer overfit.
- Hold out data — never let the optimizer see the data you will judge the strategy on. The verdict must come from genuinely unseen bars.
- Walk-forward test — tune on one window, test on the next unseen one, roll forward. The concatenated out-of-sample result is your honest expectation.
- Count your trials honestly and apply a correction — the deflated Sharpe ratio prices the luck of having searched widely.
- Demand a reason — if you cannot explain why a rule should work, in market terms, it is probably fitting noise.
Noon Barbari's walk-forward optimizer is built specifically to expose overfitting — it tunes on in-sample windows and reports the out-of-sample result so the gap between the two is visible, not hidden. Pair it with the deflated Sharpe ratio on every backtest. The free tier includes both.
Overfitting is not a flaw you eliminate once; it is a pull you resist on every strategy you build. Assume your first backtest is overfit until out-of-sample data proves otherwise — and most of your ideas will fail honestly and cheaply, which is exactly what you want them to do.
Provalo con i tuoi dati
Ogni concetto visto sopra è implementato nella piattaforma. Backtest, walk-forward, paper trading, poi passa al live — stesso set di regole in ogni fase.