What Is In-Sample Testing? Historical Data Used to Build Rules

In-sample testing is the phase of backtesting where strategy rules and parameters are initially designed, tuned, or selected using a specific partition of historical data.

MyTrade Academy
4 min read

In-sample testing refers to backtesting a strategy on the initial historical dataset used to design, discover, and refine its rules and parameters. Because the strategy's rules and parameters were tailored using this data, in-sample results often look more flattering, which is why they must still be tested on unseen data that took no part in the design.

How it works

Rule discovery: Traders examine historical charts across a chosen date range (e.g., 2021–2023) to formulate and calibrate indicator settings and trigger thresholds.

Parameter optimization: Different moving average lengths or stop distances are tested to identify which configuration performed best historically.

Optimism bias: Because parameters are selected precisely because they worked on this dataset, in-sample results almost always look better than future performance.

Why it matters

Serves as the vital starting laboratory where a trading hypothesis is first transformed into concrete, measurable rules.

Highlights the risk of curve-fitting: tuning rules too closely to in-sample quirks ensures the system will fail on new data.

Establishes the baseline model that must subsequently be validated against a separate out-of-sample dataset.

A simple market example

A trader takes historical stock data from 2022 to 2024 and tests different breakout thresholds. They find that a 20-day breakout with an ATR trailing stop produced a 58% win rate over those two years. That 2022–2024 dataset is the in-sample period.

Common mistakes

Treating in-sample results as proof of future profitability without ever testing on unseen data.

Adding excessive filter conditions until in-sample losses disappear, creating a fragile, overfitted system.

Re-testing the same out-of-sample data repeatedly, which accidentally turns it into in-sample data.

Frequently asked questions

Why is in-sample performance always higher than live results?

Because rules are chosen specifically because they succeeded on that historical sample. Random historical noise gets mistaken for recurring market truth.

What portion of historical data should be kept as in-sample?

A common rule of thumb is 60% to 70% of available historical data for in-sample rule design, reserving the remaining 30% to 40% for out-of-sample testing.

Can manual discretionary traders use in-sample testing?

Yes. Whenever you scroll through a specific historical year to craft your entry checklist, that year constitutes your in-sample testing ground.

Educational content only. Definitions describe common market usage and may vary by jurisdiction, instrument, or institution.

See the concept in a real lesson

Lesson 33 uses real market events to show how this concept works in context.

Open Lesson 33