How to Algo

Data Snooping: Why Your Best Backtest Is Likely Luck

Test 1,000 random trading rules and the best looks brilliant. How multiple testing fools backtests, how to count your trials and what deflated Sharpe fixes.

Part 11 of 20 · How to Algo · Previous: How many trades you need · Next: Placebo tests

A t-statistic of 2 means a result this strong would appear by chance about one time in twenty, if you ran one test. Nobody runs one test. You try the cash session and the full session, three thresholds, four holding periods, long only and both sides. That is already 48 variants, and among 48 tries noise will hand you a couple of t = 2 results on its own.

The best backtest from a search is not an estimate of the strategy’s edge. It is an estimate of the maximum of many noisy estimates, and maxima are biased upward. This part shows how much, and how to correct for it.

Simulated histogram of annualised Sharpe ratios of 1,000 zero-edge strategies over 7 years: 28 pass the 5% line at Sharpe 0.74, and the best of 1,000 reaches 1.28

What 1,000 random strategies look like

We simulated 1,000 strategies with zero true edge: seven years of daily returns each, drawn from a normal distribution with mean zero. Then we did what a parameter search does and looked for the best one. (Simulated; the script is not part of our research stack.)

  • The best strategy had an annualised Sharpe of 1.28, far out in the right tail of the histogram above.
  • 28 of the 1,000 cleared the one-sided 5% line at a Sharpe of 0.74, about the 2.5% per side you would expect from noise.
  • Repeating the entire search 200 times, the best Sharpe had a median of 1.23, with 90% of searches between 1.05 and 1.48.

A seven-year backtest with a Sharpe above 1 is exactly what the winner of a 1,000-strategy search on pure noise looks like. If that is how you found your strategy, the backtest has told you nothing yet.

The expected best t grows with the number of independent tries:

| Independent variants tried | Expected best t on pure noise | Bonferroni |t| for 5% overall | |---|---|---| | 1 | 0.0 | 1.96 | | 10 | 1.54 | 2.81 | | 20 | 1.87 | 3.02 | | 100 | 2.52 | 3.48 | | 1,000 | 3.24 | 4.06 |

(Expected best t: simulated, 5,000 draws per row. Bonferroni: two-sided 5% divided by the number of variants.) Read the middle column as the bar your best result must clear just to beat luck, and the right column as a conservative significance threshold. Twenty variants already push the required t to about 3.

Line chart of the best t-statistic found among N independent no-edge rules, with a 5th to 95th percentile band; the median best clears t = 2 after 35 tries and reaches 3.17 at N = 1,000

The chart draws the same curve as the middle column, as a median with its spread: the typical best of only 35 noise rules already clears t = 2, and the median best of 1,000 is 3.17.

Correlated variants and the shuffled twin

Real parameter grids are not independent. A threshold of 1.5 and 1.6 give nearly the same trades. That makes the expected maximum lower than the table says, but by how much depends on the grid. The cleanest answer is empirical: run the identical search on data where the effect cannot exist, many times, and see what the best result looks like. We call this the shuffled twin.

Our results from it:

Calendar effects on ES. Twenty-two calendar cells: weekdays, months, turn of the month. The best real cell was Monday at t = 2.75, November close behind at 2.68. On 1,000 shuffles of the same returns across dates, the best shuffled cell averaged |t| = 2.72, and 41.1% of shuffled runs beat our real best. Nothing survives the search.

The intraday clock. Thirteen half-hour cells on ES. The best real cell was t = 1.33; 93.2% of shuffled runs beat it. The real grid had less in it than noise. The intraday clock.

Time-series momentum. Nine lookbacks on ES. The best real one had a Sharpe of 0.37. Best-of-nine on shuffled returns averaged 0.50, and 75.2% of shuffled runs beat our real number. TSMOM on ES.

The Asian session sweep. A full factorial of 3,000 parameter combinations on NQ, 2,392 of them valid. Only 40.5% were positive, the best reached t = +2.29, and none exceeded 3. For the null we kept everything real (market, geometry, search) but made the claim false by drawing the session hour at random. Even with a quarter of the grid, the best null t had a median of 1.87, and 18% of null runs reached 2.29. A leave-one-year-out walk-forward of the real search lost $22,598. The 3,000-combination test.

A survivor that held. The same test can confirm. On ES RSI-2 dip buying, twenty threshold-and-hold cells were all positive. On shuffled data the same twenty-cell search produced a best result with a median of $148,755 and a 99th percentile of $284,483, so even a large real number needs context. Our best cell beat the shuffled distribution at p = 0.04, and all twenty cells were green in both halves of the sample. The one that survived.

Count every trial

The honest count includes:

  • every parameter value in every grid,
  • every session, instrument and time frame you tried,
  • every filter you added and removed,
  • every variant you ran in a notebook and forgot,
  • every earlier idea whose failure shaped this one.

The last item is uncomfortable. If you tested an idea, saw it fail, and adjusted the rules until it worked, the final version inherits all the earlier tries. That is why Part 1 insists on writing kill criteria first: it limits how many silent retries you allow yourself.

A family where most cells lose tells you the same thing without any formula: in our cash-flow + momentum test, 121 of 144 combinations lost money, so the few positive ones were the tails of noise. In our 46-claim S&P series, three claims died of multiple testing alone.

When you cannot count, raise the bar. A rough rule from our work: a result found after an open-ended search needs either t > 3.5 on its own, a shuffled-twin percentile below 5%, or confirmation on data not touched during the search.

Three ways to correct

Bonferroni. Divide the significance level by the number of tests. Simple and conservative; it treats all tests as independent, so it is too strict for correlated grids.

Holm. Sort p-values from smallest to largest and compare the k-th with α / (N − k + 1). Slightly more powerful than Bonferroni with the same guarantee.

Deflated Sharpe. Compare your best Sharpe not with zero but with the Sharpe you would expect from the best of N noise strategies of the same length, given the variance across your trials. The idea is the same as the shuffled twin, expressed as a formula.

In practice we prefer the shuffled twin because it automatically accounts for the correlation structure of the actual grid, the actual data length and the actual return distribution.

The holdout is the strongest correction

Statistical corrections tell you how surprised to be. A clean holdout tells you whether the result repeats. When we ranked all 8,191 possible combinations of thirteen order-flow signals on 2019–2023 and tested the winners once on 2024–2026, nothing in the top ranks held up out of sample; the order-flow article has the detail. Searching thousands of combinations guarantees an in-sample winner. It guarantees nothing about the next two years.

Another example of the ceiling: when we replicated twelve order-flow signals on gold, one inverted signal reached t = 2.48. Twelve signals in two directions is about 24 hypotheses, and the largest |t| from 24 noise draws is expected around 2.4. The result sits at the ceiling. We classified it as a lead, not a finding. Part 13 covers holdouts and walk-forward properly.

Checklist

  1. Count every variant you tried, including discarded ones.
  2. Look up the expected best t for that count; your result must clear it comfortably.
  3. Run the identical search on shuffled data at least a few hundred times.
  4. Report the real best result as a percentile of the shuffled bests.
  5. Prefer families where most cells are positive over one spectacular cell.
  6. Apply Bonferroni or Holm when tests are roughly independent.
  7. Confirm on a holdout that played no part in the search.
  8. Treat results at the multiple-testing ceiling as leads, not findings.

A shuffled twin asks whether the search beat noise. A placebo asks whether the signal beats a matched alternative with the same exposure. Part 12: Placebo tests and random-entry benchmarks.

Frequently asked questions

What is data snooping in trading?

Testing many variants of an idea on the same data and reporting the best one as if it were the only test. Each extra variant gives noise another chance to produce an impressive result, so the best of many is biased upward even if none of them has an edge.

Why does testing many strategies inflate the best result?

Because the best of many noisy estimates is a maximum, and maxima are biased upward. In our simulation of 1,000 strategies with zero true edge over seven years of daily returns, the best reached an annualised Sharpe of 1.28. The median best t-statistic among no-edge rules clears 2 after only 35 tries and reaches 3.17 at 1,000.

What is the deflated Sharpe ratio?

A correction that compares your best Sharpe not with zero but with the Sharpe you would expect from the best of N noise strategies of the same length, given the variance across your trials. It is the same idea as running your search on shuffled data, expressed as a formula.

Does a holdout sample protect against data snooping?

It is the strongest correction, as long as it played no part in the search and is used once. When we ranked all 8,191 combinations of thirteen order-flow signals on 2019 to 2023 and tested the winners once on 2024 to 2026, nothing in the top ranks held up. A search guarantees an in-sample winner, not the next two years.

Do I have to count the variants I discarded?

Yes. Every variant you looked at counts, including the ones you dropped because they looked bad and the ones you tried in a notebook and forgot. If you cannot count them, assume more than you think and demand a higher bar, or confirm the result on data you have not touched.

Keep reading

How to Algo

Backtest vs Live Trading: Reconciling Every Trade

Why live trading drifts from the backtest: fills, latency, data gaps, rolls and code divergence. How to replay your live engine and reconcile trade by trade.

How to Algo

Tick Data vs Bars: What Resolution Your Algo Needs

Daily bars, minute bars, ticks or order-book depth? Match data resolution to the decision your algo makes, and see what a bar hides about stops and targets.