Out-of-Sample Testing
Out-of-sample testing means judging a strategy on data that played no part in building it. The rules were fixed, the parameters were chosen, and only then was the strategy run on prices it had never seen. The data it was built on is called in-sample. The held-back data is out-of-sample. The held-back data can be a later stretch of the same history, a different fund, or the market as it unfolds in paper trading.
The reason for the split is simple arithmetic about choice. Anyone who tries enough rules and settings on one stretch of history will find some that look good on that stretch. The result says the rule fits the past. It says much less about whether the rule finds anything repeatable. A result on data that was not used for the choosing is the one number that was not shaped by the choosing.
The backtests on this site all use one window, 2021-01-04 to 2026-10-02, a stretch of 5.74 years with $10,000 to start. The same window produced every figure for the 12 strategy templates and 59 ETFs, and no part of it was held back. That is a limit of the test. The market profiles for SPY, QQQ, TLT, TQQQ, IWM and UVXY show how different one calendar looks from fund to fund, and they give real numbers for what an out-of-sample check would have to survive.
In-sample, out-of-sample and the line between them
A strategy has two kinds of inputs: the rules, such as buying when RSI(14) drops below 30, and the numbers inside the rules, such as the 30. Both get chosen by looking at data. In-sample data is the data used for those choices. Out-of-sample data is anything the choices never touched.
The line has to be drawn before the results are seen. If a strategy fails on the held-back data and the rules are then changed until it passes, the held-back data has become in-sample. It has been used for choosing. A held-back period works once, and each further look at it spends some of its value.
There are three common ways to hold data back.
- A later period. The earlier part of the history is used for building, and the later part is kept for testing. For this window that could mean building on 2021 to 2023 and testing on 2024 to 2026. Time order matters, because a rule must be judged on what came after it was designed.
- A different asset. A rule built on one fund is run on another fund that was never looked at. The test shows whether the pattern belongs to the rule or to the one fund it was found on.
- Live paper trading. The strategy runs on the real-time market feed with simulated orders. The data does not exist yet when the rule is fixed, so it cannot have influenced the choice.
An out-of-sample result usually looks worse than the in-sample one. That is expected, and the size of the drop is the useful measurement. A result that holds up on held-back data, with a drop that is modest, is more believable. A result that collapses was mostly fitted to noise.
The related ideas are on their own pages. Overfitting describes the failure that out-of-sample testing is designed to catch. Walk-forward analysis repeats the build-then-test step on rolling windows through time, so the held-back data moves forward with the history.
Why the in-sample number is the best case
The 12 templates on this site give a small example of the problem. Ranked by median CAGR across the 59 ETFs, the weekly 7% target leads at 6.61%, the monthly cycle is next at 5.46%, and the RSI(2) snapback follows at 4.74%. The momentum breakout and the 3-month momentum rule have a median of 0. A reader who picks the weekly 7% target because it topped this table has chosen the best of 12 on the window that produced the table. That choice is itself in-sample.
The ranking also changes with the measure. The weekly 7% target and the RSI(2) snapback each beat buy and hold on 34 of 59 funds. The monthly cycle beat buy and hold on 14 of 59. Median round trips range from 2 for the dip buyer to 166 for the RSI(2) snapback and 106 for the weekly target. The dip buyer has a median CAGR of 1.33% on those few trades, and a handful of trades is a small basis for any claim, in or out of sample.
The tables show the same spread in risk. The median drawdown runs from 17.47% for the RSI(2) snapback to 36.63% for the monthly cycle. The golden cross has a median CAGR of 2.05% and a median of 3 round trips, which means each fund's result rests on about 3 trades. Any ranking of the 12 on this window is a ranking of what worked in 2021 to 2026. It does not say what would rank first in a different stretch.
Parameters have the same problem on a smaller scale. A template with a 10-day and a 50-day average can be run with a 5-day or a 20-day fast average, and one of the settings will come out ahead on any given fund. The setting that wins is partly the one that suited the dates. Out-of-sample testing asks whether the winning setting still wins on data it did not see. If the best setting changes from one period to the next, the choice was mostly noise.
The in-sample result is therefore the strategy's best case, and the out-of-sample result is the more honest one. The two will differ in a direction that is nearly always the same.
One calendar, very different years
A held-back period only helps if it covers conditions different enough from the building period to be a real test. The fund profiles show how much the calendar varies.
SPY returned 30.46% in 2021, then -18.16% in 2022, then 26.18% in 2023, 24.86% in 2024, 17.72% in 2025 and 13.77% in 2026 so far. Its maximum drawdown was 24.51%, from a peak on 2022-01-03 to a trough on 2022-10-12, and it recovered on 2023-12-13. A rule built on 2021 alone would have seen a market that only rose. A rule built on 2022 alone would have seen only a decline. Neither is a sample of the whole.
QQQ had the same shape with larger swings: 29.18% in 2021, -32.39% in 2022, 54.81% in 2023, and a drawdown of 35% from 2021-11-19 to 2022-11-03. TQQQ, the three-times leveraged version, returned 90.95% in 2021, -79.07% in 2022 and 198.32% in 2023, with a maximum drawdown of 81.68%. A strategy tuned on 2023 in TQQQ would have seen a return that the other years do not support.
TLT ran the other way. It lost 4.53% in 2021, 31.21% in 2022, gained 2.79% in 2023, lost 8.07% in 2024, gained 4.23% in 2025 and lost 8.01% in 2026 so far. Its drawdown of 44.06% began on the first day of the window and had not recovered at the end. A trend rule built on TLT would learn a falling market. Applied to SPY over the same dates it would meet a rising one.
IWM returned 16.12% in 2021, -20.5% in 2022, 16.85% in 2023, 11.35% in 2024, 12.68% in 2025 and 15.12% in 2026 so far. UVXY fell every year, by 89.67% in 2021, 44.65% in 2022, 87.75% in 2023, 50.84% in 2024, 65.37% in 2025 and 52.77% in 2026 so far. Its total return was -99.94%.
The pattern across these six funds is that a single year, or a single fund, is a narrow slice. Held-back data that comes from the same regime as the building data gives a weak test, because the pattern the rule learned is still there. A useful held-back period includes conditions the rule has not seen, such as a bear year after bull years, or a fund that behaves differently from the one used for building.
This window has only one broad bear year for stocks, 2022, and the 2026 figures are for a partial year. A rule that survives out of sample here has been tested against one down year. That is a thin test, and the amount of history is a limit on every conclusion drawn from it. The answer on how many years a backtest should cover goes into that limit.
The same signal on a different fund
Testing a rule on a different fund is the simplest out-of-sample check, because it needs no waiting. The fund profiles measured one signal, RSI(14) closing below 30, and what followed.
On SPY the RSI(14) closed below 30 on 18 sessions, and the median 5-day forward return was 3.74%, against a baseline median of 0.42% for all days. On QQQ it happened on 15 sessions, with a median 5-day return of 3.69% against 0.56%. On TQQQ it happened on 18 sessions with a median of 10.3% against 1.24%. On IWM it happened on 33 sessions with a median of 1.78% against 0.18%.
On TLT the same signal appeared on 61 sessions and the median 5-day forward return was 0.02%, against a baseline of -0.14%. The 20-day median was -1.63% against -0.6%. On UVXY it appeared on 116 sessions, and the median 5-day return was -1.79%, with a 20-day median of -5.82%.
A rule of the form buy when RSI(14) is below 30 would have looked good if it had been built on SPY, QQQ, TQQQ or IWM, where oversold readings were followed by gains above the baseline. Moved to TLT, the gain is nearly gone. Moved to UVXY, the readings were followed by losses. The signal did not transfer across assets, and a person who tuned on SPY and never tried TLT would not have seen it.
The counts matter as much as the medians. The SPY result rests on 18 sessions and the QQQ result on 15. A median taken over fifteen or eighteen observations can move a long way if one or two of them change, and the observations are not independent, since oversold days cluster inside a few sell-offs. The same figures for the RSI(2) below 10 signal rest on 146 sessions for SPY and 144 for QQQ, with median 5-day returns of 0.89% and 0.8% against baselines of 0.42% and 0.56%. A larger count gives a steadier number, and still comes from one window.
The RSI mean reversion template trades the 14-day version of this signal. Across the 59 ETFs it has a median CAGR of 2.98% and a median of 15 round trips. The spread between funds in this one template is large, and a result on SPY says little about the result on UVXY.
Paper trading as the final held-back period
A later period and a different fund both draw from history that already exists, which means a determined builder can still look at it before deciding. Live paper trading removes that option. Prices arrive after the rules are fixed, and no one can fit to data that does not exist yet.
DeployQuant's product description lists this as a step between backtesting and live money. A strategy is built in plain English, from blocks or in Python, backtested on minute data, then paper traded on the live market data feed. Paper trading needs no broker. After that it can be deployed with real money in a Webull, Charles Schwab or Alpaca account. Backtests on the platform are unlimited on the free plan, and a multi-year minute backtest finishes in seconds, which makes it practical to rerun a strategy on each new stretch of data as it arrives.
A published strategy on the platform carries a backtest that the platform ran itself, on the same data and engine and with the same starting capital for everyone. Authors cannot supply their own numbers. That does not make a published backtest out-of-sample, since the author could still have tuned on the same window. It does make two published strategies comparable on equal terms.
The engine underneath, DQengine, is available as source. It backtests at second, minute or daily resolution and needs Python and free Alpaca keys for market data. Running a strategy locally on a data range the author did not use is one way to produce a held-back result independently.
Two cautions apply to paper results. A short paper run is a small sample, in the same way 18 oversold sessions are. Paper fills are also simulated, so a paper result tests the rule and says little about execution.
What an out-of-sample result can and cannot show
A held-back test lowers the chance of being fooled by a fitted result, and it does not remove the chance. Three limits are worth stating.
The first is reuse. Each time the held-back data is checked and the rules adjusted, it becomes partly in-sample. A strategy that went through ten rounds of adjustment against the same test set has been fitted to the test set. The count of rounds is part of the evidence.
The second is sample size. A rule that makes 2 round trips on a fund, as the dip buyer does on the median ETF here, has produced two data points. An out-of-sample result built on two trades cannot be told apart from luck. The golden cross median of 3 round trips has the same problem. Templates that trade often, such as the RSI(2) snapback with a median of 166 round trips, produce more observations and tighter estimates, though the window is still one stretch of 5.74 years.
The third is regime. Out-of-sample data from the same market conditions as the building data tests little. A test period that holds the same kind of year as the building period, rising stocks after rising stocks, confirms what the rule already saw. The profiles above show that stocks, bonds, leveraged funds and volatility funds each had their own calendar over the same dates, so a single hold-out period on a single fund tells a small part of the story.
The usual way to use out-of-sample testing is to decide the split, the rules and the pass criterion before looking at results, to try few variants, and to treat a large drop between the two results as the finding. A strategy whose out-of-sample figures are close to its in-sample figures has passed one test, and still has to face a market that has not happened yet.
All of the figures on this page are hypothetical backtest results from one window. They illustrate the idea and do not forecast what any rule or fund will do.
Frequently asked questions
What is out-of-sample testing?
It is testing a strategy on data that was not used to build or tune it. The data can be a later period of history, a different fund, or live paper trading. The out-of-sample result shows how much of the in-sample result was fitted to the data the rules were built on.
What is the difference between in-sample and out-of-sample data?
In-sample data is the data used to choose the rules and parameters. Out-of-sample data is data those choices never touched. The line has to be drawn before the results are seen, because a held-back period that is used to adjust the rules becomes in-sample.
Why does the same rule behave differently on different funds?
Funds have different volatility, trends and calendars. RSI(14) closed below 30 on 18 sessions for SPY, with a median 5-day forward return of 3.74%. On TLT it closed below 30 on 61 sessions with a median of 0.02%, and on UVXY the median was -1.79%.
How much data should be held back?
The page data does not pick a share. It shows the limit: the backtest window here is 5.74 years and has one broad bear year for stocks, 2022, when SPY returned -18.16%. A held-back period of a year or two is a short sample, so the number of trades in it matters as much as its length.
Can paper trading count as out-of-sample testing?
Yes. Paper trading runs on live prices that did not exist when the rules were fixed, so the rules cannot have been fitted to them. DeployQuant paper trades on the live market data feed and needs no broker. A short paper run is still a small sample.
How does out-of-sample testing relate to overfitting and walk-forward analysis?
Overfitting is the failure, tuning to noise in the history. Out-of-sample testing is a check for it. Walk-forward analysis repeats the build-then-test step on rolling windows. The glossary has pages for [overfitting](/learn/glossary/overfitting/) and [walk-forward analysis](/learn/glossary/walk-forward/).
Build it from blocks (or type it in English), backtest it on 5.7 years of minute data in seconds, tweak any parameter, then paper trade it on live data. No card, no broker needed to start.
Related terms
Backtests are hypothetical, computed by DeployQuant's engine on minute-resolution consolidated US market data (2021-01-04 to 2026-10-02, $10,000 starting capital, no margin, no fees or slippage in the headline run; buy-and-hold puts 98% of the account in at the first open, as the templates do) and do not guarantee future results. Nothing on this page is investment advice. Live trading involves risk of loss.