Skip to content

Module 04 · Robustness and the real world · Lesson 13

Overfitting, and how to catch it

Tune enough dials and any rule set will fit the past perfectly. The fit is to noise, and noise does not repeat.

8 minute read

What overfitting looks like

You test a moving-average cross: it loses. You try 20/50, then 18/47, add an RSI filter, skip Mondays, and after a hundred variations one is up 300% with a tiny drawdown. That result is mostly the best of a hundred coin-toss sequences, not a discovery.

Every input you optimise and every variation you try is a degree of freedom used to fit history. The more you use, the less the final number means.

Out-of-sample testing

Split history before you start. Develop and tune only on the first part (in-sample). Then run the finished rules, unchanged and once, on the part you never looked at (out-of-sample). If the out-of-sample result collapses, the in-sample result was largely fit to noise. If you tune again after seeing the out-of-sample, it stops being out-of-sample.

Plateaus, not peaks

Look at the results for neighbouring settings. If 20/50 is great but 19/50 and 21/50 are poor, the result is a spike: a fluke of the exact numbers. Robust rules sit on a plateau where nearby settings all behave similarly. The Lab's sensitivity heatmap is built for exactly this check.

Walk-forward

A stronger version: tune on years 1–3, test year 4; tune on 2–4, test year 5; and so on. Only the stitched-together test years count. The MT5 Strategy Tester supports forward periods for this.

Takeaways

  • Every tweak is a degree of freedom spent fitting the past.
  • Keep an untouched out-of-sample period and use it once.
  • Prefer settings on a plateau over a lone spike.
Check your understanding

One-question check

In-sample profit factor 2.4, out-of-sample 0.9. What is the most likely explanation?

Your rules, our teaching. MarketPanda provides no strategy, no settings that “work” and no signals. Everything here is education; nothing is a recommendation to trade.

Content source: Bundled MarketPanda content.