At a glance
- In-sample
- Data used to develop and fit the strategy
- Out-of-sample
- Data reserved to test the finished strategy
- Key property
- Out-of-sample data is consumed by looking at it
- Typical split
- 70 percent development, 30 percent validation
Key takeaways
- Out-of-sample data is a consumable resource: once you have used it to make a decision, it is in-sample and no longer provides independent evidence.
- The most common contamination is iterative: test, see a poor out-of-sample result, adjust, re-test. After three rounds the holdout is fully in-sample.
- Split by time rather than randomly for time-series data, because random splits leak information across adjacent periods.
- Walk-forward analysis uses data far more efficiently than a single split and produces multiple out-of-sample windows.
- When your out-of-sample data is exhausted, the remaining honest options are forward testing on new data or testing on other instruments.
Why the split exists
Any strategy can be made to look good on the data used to build it, because the building process selects rules that fit that data. The only way to estimate future performance is to evaluate on data the construction process never saw.
Full history: 2005 to 2025
Development (in-sample): 2005 to 2018 (70%)
- Explore ideas
- Choose rules and parameters
- Iterate as much as you want
Validation (out-of-sample): 2019 to 2025 (30%)
- Run ONCE, at the end
- Do not adjust anything based on the result
If the out-of-sample result is poor, the honest
conclusion is that the strategy does not work.
The dishonest conclusion is that it needs adjustment,
which converts the validation data into development data.Splitting correctly
- Split by time, not randomly. Financial data is serially correlated, so random splits put adjacent days in both sets and leak information.
- Reserve the most recent data. The recent period is the most relevant to current conditions and the most valuable as a test.
- Make the out-of-sample period long enough to matter. It must contain enough trades for the result to be informative, typically at least 30 to 50.
- Include a gap between the sets for strategies with long lookbacks, so that in-sample data does not feed into out-of-sample calculations.
- Consider splitting by instrument as well as by time. Develop on one set of markets, validate on another. This tests transferability, which is strong evidence of a real mechanism.
- Write down the split before starting. Deciding the boundary after seeing results is another form of selection.
How out-of-sample data gets contaminated
| Action | Contamination level | Remedy |
|---|---|---|
| Running the test once and accepting the result | None | This is the correct use |
| Adjusting a parameter after a poor result | Complete | The holdout is now in-sample |
| Adding a filter after seeing which trades lost | Complete | Same |
| Looking at the out-of-sample chart while developing | Substantial | Avoid viewing it at all until finished |
| Choosing between two strategies using the holdout | Partial but real | The winner is now selected on that data |
| Using a published strategy tested on the same period | Subtle but real | Others have already mined this data |
| Re-testing after a year of live trading | None if using the new data | New data is genuinely fresh |
The published-strategy case deserves note. If you read about a strategy that was developed and tested on data through 2020, that data is in-sample for that strategy even if it is out-of-sample for you. Independent validation requires data the original researcher did not have.
More efficient alternatives
- Walk-forward analysis
- Repeatedly fits on one window and tests on the next, producing many out-of-sample segments covering most of the history. Uses data far more efficiently than a single split.
- Cross-market validation
- Develop on one set of instruments and test on a different set. Strong evidence of a genuine mechanism rather than a market-specific artefact.
- Cross-asset validation
- If an effect is behavioural, it should appear in weakened form in other asset classes. Testing there uses entirely independent data.
- Forward testing
- Running the strategy live at minimal size on data that did not exist when the strategy was built. The only truly uncontaminated test, and the slowest.
- Combinatorial purged cross-validation
- A more sophisticated method that creates multiple train-test splits while purging overlapping observations. Useful for machine learning approaches.
When your clean data runs out
Eventually you will have looked at all your data. At that point no further backtesting produces independent evidence, however carefully it is constructed. Three honest options remain.
- Forward test. Trade at minimal size and accumulate genuinely new data. Slow, but it is the only fully clean evidence available.
- Test on other instruments or asset classes. If the effect is real, it should appear elsewhere. If it exists only where you developed it, that is informative.
- Simplify the strategy. A strategy with fewer parameters and a clear mechanism requires less validation, because there was less scope to fit noise in the first place.
- Accept a lower confidence level and size accordingly. If evidence is limited, trade small. Position size is the appropriate response to uncertainty.
- Do not keep re-testing. Additional backtests on used data feel productive and produce no new information, while steadily increasing the risk of fitting.
Frequently asked questions
What percentage of data should be out-of-sample?
Commonly 20 to 30 percent, reserved from the most recent period. The important constraints are that the development set contains enough trades for meaningful fitting and the validation set contains enough for a meaningful test, typically at least 30 to 50 trades in each.
Can I use out-of-sample data more than once?
Each use reduces its value, and using it to make decisions eliminates it entirely. One look at the end of development is the intended use. If you need more validation after that, obtain genuinely new data through forward testing or by testing on instruments you have not used.
Should I split randomly or by time?
By time, always, for financial time series. Random splits place adjacent observations in both sets, and because returns are serially correlated, information leaks across the boundary. Time-based splits also reflect the reality that you can only ever train on the past.
What if my strategy fails out-of-sample?
The evidence says it does not work, and the correct action is to discard it. Adjusting it and re-testing on the same data converts the holdout into development data and leaves you with no independent evidence. Discarding failed strategies is the normal outcome of honest research, not a sign of failure.
Is walk-forward better than a simple split?
Generally yes, because it produces many out-of-sample windows rather than one, uses the data far more efficiently, and simulates the periodic re-fitting you would do in practice. Its weakness is that the configuration choices can themselves be optimised, so decide them before running.
Test this idea before you trade it
Describe the rules in plain language and AlgoTrader AI turns them into a structured strategy blueprint with a configurable historical backtest, cost assumptions, and exportable code.
Build a backtestKeep reading
- BacktestingBacktesting Guide: How to Test a Strategy Honestly
- BacktestingOverfitting in Trading: How Backtests Lie
- BacktestingWalk-Forward Analysis: Testing How a Strategy Would Have Been Run
- BacktestingForward Testing: The Only Truly Clean Evidence
- Algo & QuantStrategy Development Process: From Hypothesis to Live Trading
- BacktestingMonte Carlo Simulation for Trading Strategies
Referenced by
Educational use only. This guide explains how a strategy works. It is not investment advice, not a recommendation, and no result described here is a forecast. Test any approach on historical and out-of-sample data, size positions conservatively, and never risk money you cannot afford to lose.