Skip to content
PipsMorrow
ADVANCED

Lesson 06 of 6 · Strategy and System Building

Over-Optimisation and Curve Fitting

22 min4 topics

Topic 1 of 4

By the end of this lesson

  • Recognise curve fitting in your own results
  • Prefer a parameter plateau to a parameter peak
  • Limit how many parameters a strategy is allowed

Before this lesson

Here is the uncomfortable finding that closes this track: among strategies you develop, the one with the best backtest is usually not the one that performs best live. Often it is among the worst. The reason is not bad luck — it is that the process of making a backtest better is, past a point, the process of fitting it to noise.

Degrees of freedom

Every parameter you are free to choose is a degree of freedom, and each one lets the strategy bend closer to the specific history you tested on.

Count them honestly, because they hide:

A strategy that sounds simple — six rules — already has ten free parameters
RuleDegrees of freedom
RSI(14) below 302 — the period and the threshold
1.5 ATR(14) stop2 — the multiple and the period
Only between 07:00 and 16:002 — both ends
Target at 2R1
Only when the 50 EMA is rising2 — the period and the direction rule
Skip Mondays1, and a suspicious one

With ten parameters and 150 trades you can fit almost any history. The strategy will show an excellent backtest, and what it has learned is the particular sequence of trades in your sample rather than anything about markets.

A rough guide

  • Under 5 parameters is defensible.
  • 5 to 8 demands out-of-sample evidence.
  • Above 8 is very likely fitted, whatever the test says.
  • At least 20 to 30 trades per parameter in-sample, as a minimum standard.

Caution

"Skip Mondays" is the tell to watch for in your own work. A rule with no mechanism behind it, that improves the result, is fitting. If you cannot say why Mondays would be different, the rule has learned which Mondays were bad in your sample.

Peaks versus plateaus

The single most useful diagnostic here costs nothing: after finding a parameter value, test its neighbours.

ParameterStrategy PStrategy Q
Value − 2+0.04R+0.17R
Value − 1+0.02R+0.19R
Chosen value+0.31R+0.20R
Value + 1−0.01R+0.18R
Value + 2+0.03R+0.16R

P looks better and is worthless. Its result exists at one setting and vanishes on either side, which means the market would have to repeat its past behaviour to within one parameter step. Q is flat across the whole neighbourhood — the edge does not depend on the exact number, which is what a real edge looks like.

  1. Prefer the middle of a plateau to the top of a peak, even when the peak tests higher.
  2. Test at least two steps either side of anything you choose.
  3. Treat a sharp peak as evidence of fitting, not as a discovery.
  4. Round your parameters. 14, 20, 50 rather than 13, 21, 47. Numbers that look tuned usually are.

Good to know

The plateau test works on rules as well as numbers. If removing one rule collapses the result, that rule is carrying the strategy — and it is worth asking whether it is carrying a mechanism or three specific trades.

Out-of-sample as a check, not a tuning set

The previous lesson set aside 30% of the data. Its value is entirely in being unseen, and it is spent the moment you look at it.

The pattern that destroys it, which nearly everyone runs at least once:

  1. Develop on in-sample. Looks good.
  2. Run out-of-sample. Disappointing.
  3. Adjust the rules. Re-run out-of-sample. Better.
  4. Adjust again. Better still.

By step 4 the held-out data has informed four decisions, which makes it in-sample data with extra steps. The result now looks like an honest out-of-sample test and is nothing of the kind — and that is worse than having no test, because it carries false confidence into a live account.

  • One run per strategy. If it fails, the strategy failed.
  • If you must iterate, you need a third period that has still never been seen, and the same rule then applies to it.
  • Walk-forward analysis is the disciplined version: develop on a window, test on the next, roll forward, repeat. It is more work and it is the only approach that survives repeated iteration.
  • Expect out-of-sample to be worse than in-sample. Somewhat worse is normal. Dramatically worse means fitting.

Note

A reasonable expectation: out-of-sample expectancy around 50% to 70% of in-sample. Above that is a good sign. Near zero or negative means the in-sample result was mostly fitted, and no further adjustment changes that diagnosis.

Knowing when to stop

The hardest part is that improving a backtest always feels like progress. The output goes up; the work seems to be paying off. Fitting and developing are indistinguishable from the inside, which is why you need external stopping rules.

  1. Decide the parameter budget before you start, and do not exceed it.
  2. Cap the number of iterations — twenty changes on one strategy is a reasonable ceiling, and the log from lesson 3 is how you count.
  3. Every rule needs a mechanism. If you cannot say why it should work, it does not go in, whatever it does to the result.
  4. Accept a worse backtest for a simpler strategy. Between +0.25R with four parameters and +0.40R with twelve, take the four.
  5. Stop when it is good enough, which means positive expectancy, an acceptable drawdown, and rules you will actually follow. A better backtest past that point buys nothing you can spend.

The honest summary of this track

Most of a strategy's real performance comes from things this track spent little time on — position sizing, costs, and whether you execute the rules as written. Parameter tuning is the most engaging part of strategy development and close to the least productive, which is precisely why it absorbs so much of the time people give it.

A simple strategy with four parameters, positive expectancy, a drawdown you can sit through and a deviation rate under 5% will outperform a beautifully optimised one you abandon in month three. That is the whole lesson, and it is the only defensible reason to stop optimising while the number is still going up.

Key takeaways

  • Count your degrees of freedom — a six-rule strategy often has ten, and ten parameters can fit any history.
  • Test the neighbours of every parameter and take the middle of a plateau over the top of a peak.
  • The held-out set is spent on first use; iterating against it turns a test into fitting with extra steps.
  • Set a parameter budget and an iteration cap, require a mechanism for every rule, and prefer the simpler strategy to the better backtest.

Related articles