Skip to content
Research / Education / Trading journal

TA · Professional · Part 13 of 16

Overfitting and out-of-sample: why the best backtest is the one to distrust

Try enough versions of a rule and one will shine on the past by chance. What overfitting is, why the trial count matters more than the winner's numbers, and how held-out data and walking forward tell fit from luck.

InnoMP Research · Education Desk Published 26 Sept 2026 · Updated 26 Sept 2026 10 min read
InnoMP Research cover art — the best of forty-five
In short

Overfitting is tuning a rule until it fits the noise of the sample it was tested on, so its record does not carry to new data. It comes from trials: among ten configurations with no real edge, the best is expected to show an in-sample Sharpe ratio near 1.6, and with five years of data, 45 trials can produce one that looks skilled in-sample and averages zero out of it. The defences are to count every trial, hold out data the rule never saw, walk the test forward, and prefer a parameter plateau to a peak.

Overfitting is tuning a rule until it fits the noise of the sample it was tested on, so that its record does not carry to new data. It comes from trials, not from any one test — and the number of trials is the part of the evidence that almost never gets written down. The best backtest of many is the one whose numbers mean least.

Parts 11 and 12 assumed one record, honestly kept. This part is about the records that were not kept: the versions of the rule tried and discarded on the way to the one in the notebook. They change what the surviving record means, and the tools for dealing with them are older than trading.

Fitting the signal, fitting the noise

Any set of past trades has two things in it: whatever repeats, and whatever happened once. A rule with enough adjustable parts can be bent to match both.

A rule that fits the signal, and one that fits the noise Two panels with the same seven scattered points rising from left to right. Left: a straight line runs through the cloud, missing every point by a little. Right: a wiggling curve passes through every point exactly. Notes: misses each point a little; hits every point, and nothing next. Fits the signalmisses each a littleFits the noisememorised these seven InnoMP Research
Same data. The straight line has one thing to say about it and says it about the next point too. The curve has learned where each of these seven points was, which is not information about the eighth.

In a setup the adjustable parts are the parameters: the ATR multiple on the stop, the lookback, the session filter, the minimum pullback depth, the day-of-week exclusion added after a bad Friday. Each is a knob, and each value tried on the same data is a chance to match an accident. Overfitting — curve fitting, in the older phrase — is what the setup has done when its record on the tuning data is excellent and its record on anything else is ordinary or worse. The trader who did it rarely notices, because from inside, every adjustment looked like learning.

The best of N is not the best

The mechanism is not subtle, and a 2014 paper in the Notices of the American Mathematical Society by Bailey, Borwein, López de Prado and Zhu put numbers on it. Suppose a researcher tries N configurations of a strategy, none of which has any real edge — every one has a true Sharpe ratio of zero. The best of the N, measured on the sample, will not show zero. It will show the expected maximum of N chance results, and that number grows with N.

The best of N trials, when none has any skill Five vertical bars for N equal to 2, 5, 10, 45 and 100 trials, showing the expected in-sample Sharpe ratio of the best trial when every trial's true Sharpe ratio is zero: about 0.5, 1.2, 1.6, 2.2 and 2.5. The bars rise steeply at first and then more slowly. best of N, all with no skill0.51.21.62.22.5N = 251045100Sharpe ratio of the best trial, in sample InnoMP Research
Every configuration is worthless; the best-looking one is not. Try ten and the winner is expected to show an annualised Sharpe ratio near 1.6 in sample. Try a hundred and it is 2.5. The number is a property of how many were tried, not of the winner.

The Sharpe ratio is the finance version of a ratio this group has already used: a mean return divided by the spread of returns, annualised — expectancy over its standard deviation, in the units of Part 11. The paper’s example is ten configurations, all skill-less, whose best is expected to show an in-sample Sharpe ratio of 1.57. A discretionary trader does not compute Sharpe ratios, but the logic transfers without change: the best of ten versions of a setup, tuned on the same year of charts, has an expectancy inflated by the choosing, and the error bars from Part 11 — computed as if it were the only version — are too narrow by an amount that depends on the nine that were thrown away.

That is the whole problem in one sentence. The record of the winner is not evidence about the winner until the count of losers is known.

Minimum backtest length

The paper turns the same arithmetic into a rule of thumb it calls the minimum backtest length: the years of data needed so that the best of N trials is not expected to reach a given in-sample Sharpe ratio by chance alone.

Years of data needed before the best trial means anything Two horizontal bars. Seven trials: two years of data. Forty-five trials: five years. A note attributes the figures to Bailey, Borwein, López de Prado and Zhu, 2014, at an expected in-sample Sharpe ratio of one for the best skill-less trial. data needed per number of trials7 trials2 years45 trials5 yearsBailey, Borwein, López de Prado, Zhu (2014) InnoMP Research
With two years of daily data, seven independent configurations are enough for the best skill-less one to be expected to show an in-sample Sharpe ratio of 1. With five years, forty-five. The bar for the trader is the number of trials, and it is a low bar.

The paper’s own examples are the two in the figure: five years of data support no more than about forty-five independent configurations before a skill-less one is expected to look like a Sharpe ratio of 1; two years support about seven. The authors are careful to say what the number is not. It assumes the trials are independent, which makes it conservative — ten values of the same stop multiple are not ten independent ideas — and it is a necessary condition, not a sufficient one: a backtest can be overfit on a sample far longer than the minimum. What it is, is a first answer to a question most people never ask of a record — how many trials produced it — and the authors’ central complaint is that the number is almost never reported, in academic papers or by anyone selling a result, which makes the risk of overfitting impossible to assess from the result alone.

For a discretionary trader the count is small and the data is short. A year of four-hour charts on two pairs, and a setup whose stop multiple, session filter and pullback depth were each tried at three values, is twenty-seven configurations on one year — already past the paper’s line. The record of the winner may still be fine. It is just not evidence yet.

Hold data out

The oldest remedy is to keep some of the data away from the tuning.

In sample and out of sample A single timeline band. The larger left part is shaded and labelled in sample, tune here; the smaller right part is shaded differently and labelled out of sample, run once. A dashed line separates them. A note says the second look makes it in-sample. In sampletune hereOut of samplerun oncethe second look makes it in-sample InnoMP Research
Set the last stretch aside before touching a parameter. Tune on the rest, freeze the rule, run it on the held-out stretch once, and write down what happened. If the rule is then adjusted and run again, the held-out stretch has been tuned on, and it is in-sample now.

An out-of-sample test is a rule run once, unchanged, on data it was never tuned on. If its out-of-sample record resembles its in-sample one — the same order of expectancy, an interval that overlaps — the rule learned something that persisted past the tuning data. If the record collapses, the in-sample numbers were the noise. The discipline is entirely in the word once: the held-out data is spent the moment it is looked at, and any adjustment made after looking makes the next run in-sample by definition. The paper notes the limit of the method too — a hold-out does not know how many trials came before it, so a rule that survived hold-out is still the best of N in a different sense — but as a first filter it removes most of what the previous section described.

The Intermediate level’s forward test is the same idea with the data supplied by the calendar instead of the archive: demo trades taken in real time cannot have been tuned on, because they had not happened.

Walk forward

A single split spends the data once. Walking forward spends it repeatedly and gets a longer out-of-sample record for the same history.

A walk-forward test: tune, test, slide, repeat Three rows of paired bars stepping to the right. In each row a long tuning window is followed by a shorter test window. Each row starts later than the one above so the test windows do not overlap. A fourth row at the bottom shows only the three test windows joined end to end, labelled the stitched record. tune · test · slidetuneteststitchedone out-of-sample record, never tuned on InnoMP Research
Tune on a window, test on the stretch after it, slide both forward, repeat. The test stretches never overlap and none was tuned on. Joined end to end they are one out-of-sample record covering most of the history — and the parameters chosen in each window are a record of their own.

A walk-forward test is an out-of-sample test repeated through the history: tune on the first window, test on the period after it, slide both forward by the length of the test period, and stitch the test periods together. The stitched record has the property that matters — no part of it was tuned on — and it is long enough to have error bars of its own. It also produces something a single split does not: the sequence of parameters chosen in each window. If the stop multiple that tested best is 1.5 in one window, 2.5 in the next and 1.2 in the third, the rule has no stable parameter, and re-tuning it each window is the overfitting, done on a schedule.

Plateau, not peak

The last defence is about how a parameter is chosen inside a window, and it needs no held-out data at all.

Choosing a parameter: the plateau, not the peak A curve of backtest result against the stop multiple from one to three ATRs. The curve is low at the edges and forms a broad raised region between about 1.4 and 2.4, with a single sharp spike at 1.7. The broad region is labelled plateau, the spike is labelled peak, and a note says choose inside the plateau. result by stop multiple, 1 to 3 ATRpeak: 1.7plateau: 1.4 to 2.41.02.03.0choose inside the plateau InnoMP Research
Sweep the parameter and look at the shape, not the maximum. A broad region where every nearby value works is a property of the market. A single spike is a property of this sample. The spike will be the best number in the backtest and the first to fail.

Sweep a parameter across its plausible range and draw the result against it. A rule that works has a plateau: a stretch of values where the result is similar, because the market feature the rule captures is not sensitive to the exact number. A rule fit to noise has a peak: one value that is much better than its neighbours, because that value happened to catch this sample’s accidents. The peak is always the maximum, which is why choosing the maximum is the mistake. Choose a value inside the plateau — the middle of it, not the best point on it — and the rule loses a little on the tuning data and keeps most of it elsewhere.

Key takeaway The best of N trials is expected to look good by chance, and how good grows with N. Count the trials and keep the count with the record. Hold data out and spend it once. Walk the test forward and read the parameter sequence as well as the stitched record. Inside a window, choose the plateau, not the peak.

The trial log

Everything above reduces to one addition to the journal the Intermediate level built: a log of trials. Every configuration tried, the data it was tried on, its result, and why it was dropped — including the ones that were only tried in the head for an afternoon and abandoned, since the paper’s point is that those count. The log does three things. It gives N, so that the survivor’s numbers can be read against the number of losers. It records the parameter sweeps, so that a peak can be told from a plateau later, when the sample is longer. And it makes the adjustments visible as adjustments, which is the only defence against the feeling, from inside, that each one was learning.

The paper’s last observation is the one to end on. When trials are not counted, a good backtest is not merely uninformative; on data with memory — where a period that was fit to tends to be followed by its opposite — the authors show the out-of-sample expectation of an overfit rule is negative. The customary warning that past performance does not indicate future results, they write, is too optimistic in that setting. A record that was chosen is not a weak signal. It can be a signal pointing the wrong way.

Where this leaves the record

The group is finished. A record now carries three things it did not carry at the end of the Intermediate level: error bars on its expectancy, a distribution around its drawdown, and a count of the trials behind it. A setup whose interval clears costs, whose drawdown tail is sized for, and whose trial count is small and written down has an edge in the only sense this level uses the word. The last group of the level — Parts 14 to 16 — takes a setup that has passed and turns it into something that can be run: a decision table, alert and execution rules, and a review cadence with the criteria for switching it off.

Next: From rules to a decision table — every state of the market gets a column, and the gaps and contradictions the prose hid come out.

Key facts
  • Among 10 configurations whose true Sharpe ratio is zero, the best is expected to show an in-sample Sharpe ratio of 1.57 (Bailey, Borwein, López de Prado and Zhu, 2014).
  • With 5 years of data, no more than 45 independent configurations should be tried before a skill-less one is expected to reach an in-sample Sharpe ratio of 1; with 2 years, the number is 7.
  • The number of trials behind a backtest is almost never reported, which makes its risk of overfitting impossible to assess from the result alone.
  • The out-of-sample performance of an overfit rule is expected to be around zero if the series has no memory and negative if it does.
  • An out-of-sample test holds back data the rule was never tuned on; a walk-forward test repeats that split window by window through the history.

Frequently asked questions

What is overfitting in trading?

Adjusting a rule's parameters — the lookback, the multiple, the filter, the session — until its backtest on one stretch of data looks as good as possible, with the result that the rule has learned that stretch's accidents rather than anything that repeats. An overfit rule has a superb record on the data it was tuned on and an ordinary or negative one on everything after.

How many backtest trials are too many?

It depends on how much data there is. Bailey, Borwein, López de Prado and Zhu show that with five years of daily data, trying more than about 45 independent configurations makes it likely that one with no skill at all reaches an in-sample Sharpe ratio of 1; with two years, about seven trials are enough. The number is a warning, not a licence: fewer trials than that can still overfit.

What is an out-of-sample test?

Setting aside part of the data before any tuning — the most recent year, say — and running the finished rule on it exactly once, without changing anything afterwards. If the out-of-sample record resembles the in-sample one, the rule learned something that persists. If it collapses, the in-sample record was fit to noise. A second look at the held-out data after adjusting the rule makes it in-sample.

What is a walk-forward test?

An out-of-sample test repeated through the history: tune on a window, test on the period after it, slide both forward, and stitch the tested periods together into one record that was never tuned on. It shows whether the rule's parameters are stable through time or need re-tuning every window, which is itself a sign of fit to noise.

How is this different from the sample size problem?

Sample size is about one record: how far its expectancy can be from the truth. Overfitting is about many records: if ten were produced and the best kept, the best one's expectancy is inflated by the selection, and its error bars, computed as if it were the only trial, are too narrow. The trial count is part of the evidence, which is why the log of everything tried belongs with the record.

Sources

  1. Bailey, Borwein, López de Prado, Zhu — Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance, Notices of the AMS 61(5), May 2014 — expected maximum Sharpe ratio of N trials (1.57 at N = 10), Minimum Backtest Length (45 trials for 5 years, 7 for 2), trials rarely reported, negative OOS under memoryams.org
InnoMP Research · Education Desk

Trading education from first principles — position sizing, risk, market structure and the habits that keep accounts alive. Written for someone who has never opened a chart, with a diagram at every step.

Published 26 Sept 2026 · Updated 26 Sept 2026

Disclaimer: This content is provided for general informational purposes only and does not constitute investment advice, an offer, or a solicitation to buy or sell any financial instrument. It has been prepared without regard to your individual financial circumstances or objectives. Trading CFDs involves a high risk of loss.

Related notes

InnoMP Research cover art — a number and its doubt
Trading journal

Expectancy with error bars: how sure the record lets you be

A record says +0.25R per trade. The question is how far from that the truth could be. How to put a standard error and a confidence interval on expectancy, and how many trades it takes to tell an edge from zero.

9 min read