How backtesting actually works

A backtest replays a fixed set of rules over historical data to see what those rules would have done. The machinery is simple. The ways it misleads you are not.

Educational background for the strategy builder. Nothing here is investment advice.

The one-sentence version

A backtest converts a vague idea — “buy stocks that have been going up” — into an unambiguous sequence of simulated decisions, then reports what that sequence produced.

The conversion is the whole point. “Going up” has to become which stocks, measured over what window, rebalanced how often, holding how many positions, at what cost. Most of the value of running a backtest comes from being forced to answer those questions before you ever see a result.

The loop, step by step

Every backtest engine, from a spreadsheet to an institutional platform, runs some version of this loop:

StepWhat happensWhere it goes wrong
1. Define the universePick the set of securities the strategy is allowed to hold.If the list is today's survivors, the test is already biased. See survivorship bias.
2. Compute a signalAt each decision date, score every candidate on some rule — trailing return, a moving-average cross, a valuation ratio.Using any data published after that date is look-ahead bias.
3. Build the portfolioTurn scores into weights: top N names, equal weight, rank weight, whatever the rule says.Weighting choices quietly drive most of the result, and are easy to tune after the fact.
4. Rebalance on a scheduleMove from yesterday's portfolio to today's target on the chosen cadence.Daily rebalancing looks great on paper and is often uninvestable after costs.
5. Charge costsSubtract commissions, spread, and slippage on every share traded.A zero-cost assumption flatters high-turnover strategies enormously.
6. Compound forwardApply the period's returns to the portfolio and record the new equity value.Ignoring delisted positions silently deletes your worst outcomes.

Run that loop across every date in the sample and you get an equity curve: the simulated value of the account over time. Every metric below is just a different summary of that one curve.

What comes out the other end

A single equity curve gets compressed into a handful of numbers. Each answers a different question, and reading only one of them is how people talk themselves into bad strategies.

MetricQuestion it answersWhat it hides
CAGRHow fast did it compound?Says nothing about the ride. A 20% CAGR through an 80% drawdown is unholdable in practice.
Sharpe ratioHow much return per unit of volatility? (Sharpe, 1966)Treats upside and downside volatility identically, and assumes returns are reasonably well-behaved.
Max drawdownWhat was the worst peak-to-trough loss?A single historical worst case. The next one can always be deeper.
ConsistencyWhat share of periods were positive?Can look excellent right up until one catastrophic period.
VolatilityHow much did returns bounce around?Low historical volatility is not a promise of low future volatility.

StratPick's composite score exists precisely because no single one of these is trustworthy alone.

Six ways a backtest misleads you

In rough order of how often they ruin an otherwise sensible test:

In-sample, out-of-sample, and the honesty problem

In-sample is the data you looked at while building the strategy. Out-of-sample is data the strategy never saw during design. Only the second kind is evidence.

The trap is subtle: out-of-sample data stops being out-of-sample the moment you use it to make another decision. Check your held-out period, dislike the result, adjust one parameter, and check again — you have just folded that period into your in-sample set. Do it a few times and you have no clean test left, only a more elaborate way of fitting the same noise.

The only fully honest out-of-sample test is forward time: data that did not exist when the strategy was fixed. It is slow, unglamorous, and the only version that cannot be quietly re-run.

Reading someone else's backtest

A short checklist worth applying to any impressive equity curve, including the ones on this site:

That last one matters more than it sounds. A great many strategies that look clever are just leveraged beta wearing a costume.

Frequently asked questions

What is backtesting?

Replaying a fixed set of trading or allocation rules over historical market data to see what those rules would have produced. It turns a vague idea into a specific sequence of simulated trades and a measurable equity curve.

Is a good backtest a reliable predictor of future returns?

No. A backtest describes one path history actually took, not the distribution of paths it could have taken. Strong results can come from genuine edge, from luck, or from having tried many variations until one fit. Backtests are far better at rejecting bad ideas than confirming good ones.

What is look-ahead bias?

Using information in a simulated decision that would not have been available at the time. Restated financials, later-published index membership, and full-period averages are the usual culprits. It inflates results invisibly.

How many strategies can I test before the results stop meaning anything?

Sooner than most people expect. Every extra variation raises the odds that your best result is noise. The multiple-testing literature in finance argues that standard significance thresholds are much too lenient once the number of strategies searched is taken into account.

What is the difference between in-sample and out-of-sample testing?

In-sample is the data used while designing the strategy; out-of-sample is data it never saw. Only out-of-sample results carry evidential weight, and they stop counting as out-of-sample the moment you use them to make another tuning decision.

Further reading