Home / Guides / In-sample and out-of-sample testing

In-sample and out-of-sample testing

In-sample data is the part of the history used to choose a rule's settings. Out-of-sample data is a part kept unseen until the rule is fixed, then used once to see how it does. The point is that a rule can always be made to fit the data it was tuned on, so only the unseen part says anything about new data.

Last updated 28 Nov 2026. Reviewed by the Custom Trading Platform education desk. Every figure on this page is sample arithmetic, shown in full.

The routine, in order

  • Decide the split before looking at results, for example the first 70 percent in-sample and the last 30 percent out-of-sample.
  • Choose the rule and its settings using the in-sample part only.
  • Fix the settings. Do not change them after seeing the out-of-sample result.
  • Run the out-of-sample part once and record the result with the costs counted.
  • If you change the rule after that look, the unseen part is no longer unseen.

Worked example: the split

A history of 1,000 bars is split into 700 and 300. A rule tuned on the first 700 shows a gain of 12 percent. The same rule on the last 300 shows 1 percent. These are sample figures.

The fall from 12 to 1 is what overfitting looks like: the settings captured the quirks of the first part. A rule that shows 12 and then 10 on the unseen part is more convincing, though one test of one split is still thin evidence.

Worked example: why trying many settings finds a winner

Suppose a test of no real value has a 5 percent chance of looking good by luck. Try 20 settings and the chance that at least one looks good is 1 minus 0.95 to the power of 20, which is 64.2 percent. Try 100 settings and it is 1 minus 0.95 to the power of 100, which is 99.4 percent.

Settings triedChance at least one looks good by luck
15.0 percent
2064.2 percent
10099.4 percent

This is why the number of settings tried has to be reported next to the best result, and why the best of many in-sample results is the one least worth believing.

How we test

Our own tests keep part of the history unseen, fix the rule before looking, count costs, and say how many rules were tried. Their method is on the methodology page. Where a result held up on the unseen part no better than luck would give, the test pages say so.

What it cannot tell you

An out-of-sample result is still one sample of one period, so it can be lucky too. It also cannot say whether a market will change. For the full routine of a test, see how to backtest a trading strategy.

Sources and method

Every figure on this page is sample arithmetic, shown in full, as of 28 Nov 2026. Each result was worked a second way before it was kept. No market data, price quote, broker term or return is stated as fact. How we check numbers is on the methodology page, and corrections go through contact.

How we will test it

We will recompute every figure in a second spreadsheet and repeat the worked example at a second set of inputs. No result is claimed. Last tested: not yet, results pending.

Questions people type

What is out-of-sample testing? Testing a fixed rule on data that was kept unseen while the rule was chosen.

What is overfitting? Choosing settings that fit the quirks of past data and so do worse on new data.

How much data should I keep unseen? There is no fixed rule. A common split is 70 to 30, decided before looking at any result.

Why does testing many settings give false winners? Each try has a chance of looking good by luck, and the chances add up: 20 tries give about a 64 percent chance of at least one.

Related

Glossary, backtesting, how to backtest a trading strategy, survivorship bias, methodology, Disclaimer.

Start free: create a free account to get the weekly note on tools and tests.

Education only. Nothing here is financial advice or a signal.