In-Sample vs Out-of-Sample: Why Unseen Data Is the Real Test
In-sample data is the part of history used to build or optimize a strategy. Out-of-sample data is the part it never saw, used only to test it. In-sample results tend to be optimistic, because the settings were chosen to fit that data. Out-of-sample results are the more honest estimate.
A simple picture
Think of a student who studies with the exact exam questions. A perfect score proves nothing. Give the same student new questions on the same subject, and the score means something. In-sample is the practice exam; out-of-sample is the real one.
Why in-sample results tend to be too good
An optimizer tries many combinations and keeps the best. Some of that "best" is real edge, and some is random luck that happened to suit those years. On new data, the luck does not repeat. So the out-of-sample result is usually lower — the question is how much lower. (Not always: a calm in-sample period followed by a better out-of-sample one can reverse the gap. That says more about the market than about the strategy.)
How big should the out-of-sample part be?
There is no single right number. Common splits give the out-of-sample part 15–30% of each window. The trade-off:
- Too small: too few trades to judge anything.
- Too large: the in-sample part gets too short to optimize on, and the strategy is re-tuned less often.
Comparing several splits and preferring one that holds up across them is safer than chasing the single best-looking one. But that comparison is itself a choice made by looking at results, so the data it used is no longer untouched: it has become development data. Only a separate final holdout, kept out of every choice, gives the last honest check.
The rules that keep out-of-sample data honest
- Never optimize on it. Not directly, and not by "just checking" and then adjusting.
- Never pick between strategies by their out-of-sample results and then present that result as unbiased. Once it decided something, it became in-sample.
- Look at it once, at the end, with rules decided in advance.
- Keep a final holdout if possible: the most recent stretch, untouched by every optimization and every choice — split, strategy, settings — until the very last check.
In-sample vs out-of-sample in a walk-forward test
A walk-forward test repeats the in-sample / out-of-sample split many times, moving forward through history. Every out-of-sample period is tested with inputs chosen only from the data before it. Joined together, those periods give a much larger out-of-sample sample than a single split.
In WalkStrat
WalkStrat's WFO Config tab is a fast scouting step: it compares combinations of segment counts and out-of-sample percentages on results that are already optimized — useful for narrowing down a layout, but not the test itself. The real walk-forward test then re-optimizes each in-sample window from scratch and trades the winner on the out-of-sample window that follows; windows never share a day. An optional holdout at the end is never seen by the optimizer. More in the documentation.