Back to Trading Styles & Strategy Development

Trading Styles & Strategy Development · Pro · 4 min

Overfitting and curve fitting

You can explain how testing many rule variations creates backtests that look excellent but fail later, and name practical defenses against overfitting.

Proof, or a lucky fit?

A backtest with a smooth, steadily rising equity curve looks like proof that the rules work. Strategy sellers show such curves for exactly that reason.

Often the curve proves something else: that someone tried many variations of the rules until one happened to fit the past. It is one of the most common and most expensive mistakes in strategy development, and it is easy to make without noticing.

Best of 500 by chance

Overfitting, also called curve fitting, means tuning rules so closely to past data that they capture random noise instead of a repeatable pattern. The rules then fit history beautifully and fail on new data.

It happens through the search itself. Suppose you test a moving-average rule with 500 combinations of lengths, stops and targets. Even if none of them has any edge, some will look excellent on the test period by luck alone. Picking the best of 500 means picking the luckiest.

Value bars Fictional example: the best fit among 500 tested parameter combinations reaches a profit factor of 2.10 on the test data but only 0.92 on later data. A simple rule with few parameters reaches 1.30 on the test data and 1.20 later. PROFIT FACTOR, FICTIONAL RULE SETS Best fit, test 2.10 Best fit, later 0.92 Simple, test 1.30 Simple, later 1.20

In this fictional example, the best of 500 combinations reaches a profit factor of 2.10 on the test data and 0.92 afterwards. A simple rule with two parameters reaches 1.30 and holds up at 1.20.

Research describes the problem precisely. Bailey, Borwein, López de Prado and Zhu (2014) showed that high backtest performance is easy to achieve after trying a relatively small number of configurations, and that a backtest that does not report how many configurations were tried cannot be judged. Harvey and Liu (2015) proposed ways to discount reported results for the number of tests behind them.

Test once on unseen data

Practical defenses:

Steps A simple defense: develop and tune the rules on the first 70% of the data, lock them, then test them once on the remaining 30% that was never looked at. 1 Develop on 70% 2 Lock the rules 3 Test once on 30%

Develop and tune only on the first part. Then lock the rules and test them once on the out-of-sample part. If you tune again after seeing that result, it is no longer out of sample.

Common mistakes

The takeaway

Try enough variations and some will look brilliant by chance. Fewer parameters, untouched test data and simple rules protect against overfitting.

Check yourself

Quick quiz

4 questions. Instant feedback, nothing is saved.

  1. 1Tap the result that reveals the overfitting.

    Tap the chart.

    Value bars Chart for the question: Tap the result that reveals the overfitting. PROFIT FACTOR, FICTIONAL RULE SETS Best fit, test 2.10 Best fit, later 0.92 Simple, test 1.30 Simple, later 1.20

    The best of 500 variations drops from 2.10 to 0.92 on new data. Its test result was largely luck from searching so many combinations.

  2. 2Why does testing many variations raise the risk of overfitting?

    Bailey and coauthors showed that the more configurations are tried, the more likely the best one is overfit.

  3. 3What is out-of-sample data?

    Only data the rules have never 'seen' can show whether they generalize.

  4. 4Which rule set is usually less prone to overfitting?

    Every extra parameter gives the rules more freedom to fit noise in the past.

of 4 correct.

Sources

Back to Trading Styles & Strategy Development