Out-of-Sample Testing for Trading Strategies | Edgecraft
FoundationsIntermediate

Out-of-sample testing: protecting yourself from luck

9 min read

If the optimizer touched the data, that data can no longer judge the result. This is the one rule. Everything else in this article is consequences.

The split

Divide your history into two parts with two jobs. In-sample data is what the optimizer sees while it searches. It finds the strategy. Out-of-sample data is what the optimizer never sees. It judges the strategy.

A strategy that shines in-sample and dies out-of-sample was fit to one history's noise. A strategy that holds up out-of-sample has cleared the lowest bar there is. Not the highest. The lowest. Most strategies never clear it, and the traders who skip the test never find out, until the account finds out for them.

Why this works

An optimizer selects whatever scored best on the data it was shown. Some of that score is edge. Some is noise that happened to line up. The optimizer cannot tell the difference. Telling the difference was never its job.

The held-out data carries its own noise, and that noise is uncorrelated with the noise the optimizer fit. A pattern that performs in both places is probably signal, because noise does not repeat on request. That is the entire trick. It is not a guarantee. Out-of-sample results can be lucky too. But it is the strongest single defense against overfitting that exists, and skipping it means deploying on hope.

The ways to split

Simple holdout. Fit on the first 70 percent, judge on the last 30. Easy, and mostly good. Its weakness: if a regime change lands in the holdout, you are judging the strategy against one unusual period and may get the wrong verdict in either direction.

Walk-forward. Fit on months 1 through 12, judge on month 13. Slide. Fit on 2 through 13, judge on 14. Repeat to the end. Every parameter set is always judged on data just after its fitting window, which is exactly the situation you face live. The strongest realistic test. It costs compute. Compute is cheaper than tuition.

K-fold. A machine-learning tool that shuffles time. Markets are ordered sequences. Shuffling time leaks the future into the past. Wrong tool here.

Forward testing. Judge on data that did not exist when you optimized. Paper or small live. Nothing can leak from a future that had not happened. The cost is patience, which is the cost traders least like paying.

Crypto makes the window bigger

Three local facts change the arithmetic:

  • Regimes persist. Crypto regimes run long. A 6-month holdout can sit entirely inside one trend and tell you nothing about chop.
  • Funding rotates slowly. A holdout that never spans a funding flip has not tested a perp strategy's cost structure.
  • Structural breaks happen. Halvings, exchange collapses, ETF approvals. A holdout that straddles one is informative about shocks and misleading about normal days. Know which question your window answers.

The practical rule: the holdout should contain at least one full trend reversal and at least one funding flip. That usually means 9 to 18 months held out. Longer than instinct suggests. Instinct is why most holdouts are too weak.

Reading the verdict

  • Out-of-sample roughly equals in-sample. Probably real. This is the outcome you wanted.
  • Out-of-sample is about half. Some edge, some fit. Common. Simplify the rules and optimize less hard. Do not deploy and hope.
  • Out-of-sample at or below zero. Fit. Do not deploy. No in-sample brilliance appeals this verdict.
  • Out-of-sample drawdown much deeper. The strategy is more fragile than its fitting period admitted. Cut size or rethink.

Why in-sample results are almost worthless

Be blunt about this. The optimizer's only job is to make the in-sample curve beautiful. That is the goal function. Of course the curve is beautiful. Reporting it as evidence is reporting that the optimizer ran.

It is the same mistake as quoting training accuracy in machine learning with no test set, and it is the most common self-deception in retail systematic trading. It does not feel like deception, which is why it is common. The numbers are real. They answer a different question than the one your money is asking.

How Edgecraft handles this

Every Edgecraft optimization study scores every parameter set on held-out data, and shows the in-sample and out-of-sample numbers side by side. The defaults hold out a serious share of history, sized for crypto's long regimes, not a token slice. A wide gap between the two numbers raises a warning before deployment. And forward-test mode lets a strategy accumulate true future evidence before real size goes on. The market will run the out-of-sample test either way. The only choice is whether it runs on your money.

Continue learning

Build your process around evidence

Join the Edgecraft waitlist and follow the development of a strategy intelligence platform built for realistic testing and deeper strategy analysis.

Educational content only. This article is not financial advice and does not guarantee any trading outcome. Trading involves risk.