The intuition: lucky coins
Imagine 100 people each flip a fair coin 10 times. Nobody has any skill, because a fair coin has none. Yet a few people will probably flip 8, 9 or even 10 heads. If you then announce "here are the star flippers" and ask them to flip again, they will drift back to roughly 5 heads out of 10.
Backtesting works the same way. A trading rule is a coin with an unknown bias. When you test one rule and it performs well, that is mildly interesting. When you test 100 rules and show only the best, you have selected the luckiest flipper, not the most skilful one.
This is data snooping (also called data mining bias or the multiple comparisons problem): using the same dataset to generate, test and choose among many ideas, then treating the winner as if it were the only idea you ever tried.
The mechanics: what a 5% threshold really means
Most performance tests use a significance threshold, commonly 5%. The idea: if a rule had no real edge, there would be only a 5% chance (a p-value of 0.05) of seeing results at least this good by luck. Passing the test is meant to be unusual.
That 5% is a property of a single test. It is a false-positive rate: out of many useless rules, about 5% will pass anyway.
Now the arithmetic of repetition. If each useless rule has a 5% chance of looking significant, it has a 95% chance of not looking significant. For independent tests:
- Probability that none of N useless rules passes = 0.95^N
- Probability that at least one passes = 1 − 0.95^N
| Number of tests | Chance at least one useless rule passes | Expected number of false passes |
|---|---|---|
| 1 | 5% | 0.05 |
| 10 | about 40% | 0.5 |
| 20 | about 64% | 1 |
| 100 | over 99% | 5 |
The figures are straightforward probability, not market data. The conclusion is uncomfortable: with 100 tests, finding a "significant" rule is not evidence of skill. It is the expected outcome even if every rule is noise.
In practice tests are rarely fully independent. Many rules share the same inputs (for example, moving averages of 20, 21 and 22 days). That lowers the effective number of independent tests, but it does not remove the problem. It also hides it, because the true count feels smaller than it is.
How snooping happens without you noticing
Snooping is not only running a loop over 100 parameters. It also looks like:
- Trying a 50-day average, then 100-day, then 200-day, then a different asset, then a different period.
- Adding a filter after seeing where the strategy lost money, then another filter after that.
- Reading research, noticing which ideas "worked" on the historical sample, and testing those first.
- Dropping a bad year because "it was unusual", after seeing the result.
- Trying a variation each evening for a month, remembering only the one that stuck.
Each choice is a fork in the road. The more forks you explore on the same data, the more the final path reflects the quirks of that data rather than anything repeatable.
Bonferroni-style intuition: raise the bar as the count rises
If more tests create more chances for luck, the fair response is to make each test harder to pass. The simplest approach is the Bonferroni correction: divide your desired overall threshold by the number of tests.
Suppose you want only a 5% chance of any false positive across your whole research effort, and you ran 100 tests. The per-test threshold becomes:
0.05 ÷ 100 = 0.0005, or 0.05%
A rule must now look like a one-in-2,000 fluke to count as significant. Check the effect: with a 0.05% threshold per test, the chance that at least one of 100 useless rules passes is about 1 − 0.9995^100, which is roughly 5%. The overall error rate is back where you wanted it.
Bonferroni is conservative. It can reject real edges, especially when tests are highly correlated, and there are less blunt methods in the statistics literature. But as intuition it is excellent: the evidence needed to believe a result should grow with the number of things you tried. A Sharpe ratio that is persuasive from one pre-specified idea is much less persuasive as the best of 200 variants.
Worked example: the best of 100 rules
A researcher tests 100 simple entry rules on one index's daily history. The rules are, unknown to the researcher, random: each one buys or sells on arbitrary signals with no link to future prices. The hypothetical outcomes:
- Roughly 5 rules show a p-value below 0.05.
- The best one shows an annualised return of 9% in the backtest (an illustrative figure) against 5% for buy-and-hold.
- The researcher writes up the rule with an appealing story about why it should work.
What has happened? The story was written after the result. The 9% is the maximum of 100 noisy draws, and the maximum of many draws is biased upward by construction.
Applying the correction: the best rule's p-value was, say, 0.012. Against the naive 0.05 threshold it passes. Against the Bonferroni threshold of 0.0005 it fails by a wide margin. The honest reading is "this is about what luck produces from 100 tries".
Now suppose the rule is run on data it has never seen. A random rule has no reason to keep its edge, so the expected out-of-sample return reverts toward zero excess return, minus costs. That decay between the backtest and live trading is the typical signature of snooping.
The trial log: your defence
You cannot correct for a number you do not know. The practical habit is a trial log, a simple spreadsheet or document in which you record every variation you test, including the ones you abandon. Useful columns:
- Date and the hypothesis, written before the test.
- The exact rule and parameters tried.
- Data used (asset, period).
- Result, whatever it was.
- Decision and reason (kept, dropped, modified).
- Running count of total trials for this research question.
The log does three things. It gives you N for a Bonferroni-style adjustment. It exposes drift, such as discovering you have quietly tested 60 versions of one idea. And it discourages casual fishing, because writing down "trial 47" is sobering.
Practical safeguards beyond the log
- Write the hypothesis first. An economic reason stated before testing is worth more than one invented afterwards.
- Limit the search space. Fewer parameters and fewer variants means fewer chances for luck.
- Hold out data. Reserve a final period that you touch once. See the lesson on in-sample versus out-of-sample testing.
- Prefer plateaus to peaks. If nearby parameter values also work, the result is more credible than a lone spike.
- Use walk-forward testing so that choices are always judged on data not used to make them.
- Discount the headline. Treat the best backtest as an upper bound, not an expectation.
Common mistakes
- Counting only the winner. Reporting one rule as if it were the only one tested hides the other 99.
- Reusing the holdout. Each time you peek at the holdout and adjust, it becomes part of the training data.
- Believing a story built after the fact. Almost any result can be given a plausible explanation once you know it.
- Assuming correlated variants count as one. Slightly different parameters are still multiple looks, even if they are not fully independent.
- Ignoring the work of others. If many people test similar ideas on the same public data, the collective number of trials is large, even if yours is small.
- Over-correcting into paralysis. The aim is calibrated scepticism, not rejecting everything. A strong effect, a sound rationale and confirmation on unseen data can survive a strict standard.
Try this
You do not need market data to feel the effect.
- In a spreadsheet, generate 100 columns of 250 random daily returns, each with an average of zero (random numbers centred on zero will do).
- For each column, calculate the average return divided by its standard deviation, then scale by the square root of 250 to get an annualised ratio.
- Sort the 100 results and note the best one. It will usually look respectable.
- Generate a fresh 250 days for that same column and recalculate. Record how far it falls.
- Write down your trial count (100) and compute 0.05 ÷ 100. Ask whether your best result would have met that bar.
If you repeat the exercise a few times, the best of 100 will consistently look good and consistently fail to repeat. That pattern is the lesson.
This material is educational and uses hypothetical numbers throughout. It is not a recommendation of any strategy or product.