Backtesting your strategy: the pitfalls that flatter results
Backtesting runs a strategy against historical data to see what would have
happened. Done honestly, it is the cheapest education in trading. Done lazily, it
is a machine that manufactures confidence. The three result-killers are
overfitting, survivorship bias, and look-ahead bias - and each one flatters the
curve.
Overfitting: the curve that memorizes the past
Tweak parameters until history looks beautiful and you have not found an edge;
you have found the noise pattern of that specific dataset. The strategy then
fails live, because live data is not the dataset.
Signs you are overfitting:
- More than a handful of parameters, each tuned to the decimal
- Performance collapses when you shift the test window by a few months
- Rules that only work on one asset or one period
Defense: keep rules few and round-numbered, test on out-of-sample data you did
not tune on, and check that nearby parameters also work. A real edge is a
plateau, not a spike.
Survivorship bias: testing on the winners
Backtesting "the top 20 coins of 2021" tests coins that survived to be ranked.
Half the tokens that existed then are dead or delisted now. Strategies tested
only on survivors look far better than the same rules applied to the universe as
it existed at the time.
Defense: build the test universe as it was back then, including the assets that
later failed - or accept that your results are an upper bound, not an estimate.
Look-ahead bias: using information you did not have
The classic bugs: filling at a close you could not have known at decision time,
using the day's high and low to trigger intrabar orders, or computing an
indicator on the full bar and trading it at its open. Each one quietly adds
returns that live trading cannot deliver.
Defense: decide at the bar's open or the previous close, fill at the next open or
a realistic limit, and compute signals only on completed data.
The honest workflow
- Write the rules before looking at any data
- Test in-sample, then validate on a holdout window
- Include fees, spread, and slippage - real costs, not zero
- Forward-test before real size; that is the step most people skip
The takeaway
A backtest is a hypothesis generator, not a verdict. Treat a beautiful curve as
guilty until proven out-of-sample, fee-inclusive, and forward-tested. The three
biases do not announce themselves; they hide in parameters, universes, and fills.