At a glance
- Purpose
- To find reasons the strategy will not work
- Biggest risk
- Optimism from bias, not from bad code
- Minimum requirements
- Clean data, real costs, conservative fills
- Validation
- Out-of-sample, walk-forward, and Monte Carlo
Key takeaways
- The purpose of a backtest is to disprove a strategy cheaply. A test designed to confirm your idea will always succeed and teach you nothing.
- The three biases that destroy most backtests are survivorship, look-ahead, and overfitting, and all three inflate results in the same direction.
- Costs must be modelled explicitly: spread, commission, slippage, financing, and market impact. Omitting them makes most short-horizon strategies look profitable.
- Execution assumptions matter more than entry rules. Assuming fills at the close of a signal bar is the single most common source of inflated results.
- A result is only meaningful after out-of-sample validation, parameter robustness checks, and a Monte Carlo view of the possible drawdowns.
What a backtest is for
A backtest answers one question: if these exact rules had been applied over this period, what would have happened? It does not predict the future, and it cannot establish that an edge exists. What it can do, reliably, is show that an idea would have failed, which saves money and time.
That framing changes how you run the test. Instead of iterating until the equity curve looks good, you actively search for the assumption that makes the result disappear. If the strategy survives that search, you have something worth forward testing. If it does not, you have learned it cheaply.
Data requirements
- 1
Use point-in-time data
Index membership, fundamentals, and sector classifications change and are restated. Your test must see only what was known on each historical date.
- 2
Include delisted and merged instruments
Omitting them is survivorship bias and inflates almost every equity strategy substantially.
- 3
Handle corporate actions correctly
Splits and dividends require adjustment, but adjusted prices are not the prices at which trades occurred, which matters for any rule referencing specific levels.
- 4
Check for bad prints and gaps
Erroneous ticks can trigger stops and create phantom signals. Screen for prices that deviate implausibly from surrounding bars.
- 5
Get futures rolls right
Back-adjusted continuous contracts change historical prices and can produce negative values. The adjustment method must match how you intend to trade.
- 6
Use enough history
Long enough to include at least one full market cycle, and ideally several regimes: rising and falling rates, high and low inflation, bull and bear equity markets.
Execution assumptions
| Assumption | Optimistic version | Conservative version | Impact |
|---|---|---|---|
| Fill timing | At the close of the signal bar | At the next bar open | Often large; the gap between them is real |
| Limit orders | Filled when price touches | Filled only when price trades through | Large for mean reversion strategies |
| Stops and targets in one bar | Assume the target was hit first | Assume the stop was hit first | Can invert the result entirely |
| Slippage | None | Half the spread plus an impact term | Decisive for short-horizon strategies |
| Commission | Ignored | Actual broker schedule with minimums | Large at small position sizes |
| Liquidity | Unlimited | Capped at a fraction of average volume | Large in small caps and thin instruments |
| Shorting | Always available and free | Borrow checked and charged | Can eliminate short-side results |
Modelling costs properly
Cost per round trip =
spread cost (half the spread on entry + half on exit)
+ commissions (both sides, including minimums)
+ slippage (a function of order size vs volume)
+ financing (for leveraged or overnight positions)
+ borrow (for short positions)
Simple impact model for slippage:
impact = k x spread x sqrt(order size / average volume)
with k around 1 for liquid markets
Express the total as a fraction of expected profit per trade:
Cost ratio = cost per round trip / average winning trade
Below 5% -> comfortable
5 to 15% -> viable with a genuine edge
Above 15% -> the strategy is probably not viable
Above 30% -> costs are the strategyValidating what survives
- 1
Hold out data from the start
Reserve the most recent 20 to 30 percent before you begin. Do not look at it until the strategy is finalised, and if you use it to make changes, it is no longer out of sample.
- 2
Check parameter robustness
Vary each parameter by 20 to 50 percent. Require a plateau of acceptable performance, not a spike. See overfitting.
- 3
Run walk-forward analysis
Repeatedly fit on one window and test on the next. This uses data efficiently and simulates periodic re-optimisation. See walk-forward analysis.
- 4
Run a Monte Carlo on the trade sequence
Reshuffle trades thousands of times to see the distribution of possible drawdowns. History produced one ordering; you need the range.
- 5
Test across instruments and regimes
A real effect should appear, in weakened form, in related markets. An effect confined to one instrument in one decade is probably noise.
- 6
Count your tests
Record how many variants you tried. Twenty tests at the 5 percent level produce one spurious winner by construction, and the reported statistics must be adjusted for that.
What to report
- Expectancy in R and the full trade distribution, not just the average.
- Maximum drawdown, drawdown duration, and longest time underwater. Duration matters more than depth for whether you would have continued.
- Number of trades and the concentration of returns: how much came from the top five trades?
- Performance by year and by regime, so that a single exceptional period is visible rather than hidden in the average.
- Sensitivity to costs: re-run with double your assumed costs and report the result.
- Sensitivity to start date: shift the window by a few months and confirm the conclusion holds.
- The number of variants tested, which is the single most important disclosure and the one most often omitted.
Frequently asked questions
How much data do I need to backtest a strategy?
Enough to include several market regimes and to produce a statistically meaningful number of trades, which generally means at least 10 to 20 years for daily strategies and at least 100 to 300 trades. Slow strategies compensate for few trades per year by testing across many instruments simultaneously.
Why do my live results differ from my backtest?
Usually some combination of optimistic fills, unmodelled costs, survivorship or look-ahead bias, overfitting from multiple tests, and hesitation in execution. Compare realised slippage and win rate against backtested values to identify which is dominant, because the remedies are entirely different.
What is a good Sharpe ratio for a backtest?
Be suspicious of high values. A backtested Sharpe above roughly 2 for a retail strategy usually indicates a bias rather than an exceptional edge. Live Sharpe ratios of 0.5 to 1.0 are respectable for individual traders, and backtests typically overstate the eventual live figure considerably.
Should I optimise my parameters?
Only within a search for robustness rather than for the best value. Plot performance across the parameter range and choose from the middle of a broad plateau. If the peak is narrow, the result is fitted to noise. Every optimisation run also increases the number of tests, which must be accounted for.
Can I trust backtests published by others?
Only if they disclose data source and survivorship handling, execution and cost assumptions, the number of variants tested, and the out-of-sample results. Most published backtests omit at least two of these, which makes the reported figures uninterpretable rather than merely optimistic.
Test this idea before you trade it
Describe the rules in plain language and AlgoTrader AI turns them into a structured strategy blueprint with a configurable historical backtest, cost assumptions, and exportable code.
Build a backtestKeep reading
- BacktestingOverfitting in Trading: How Backtests Lie
- BacktestingWalk-Forward Analysis: Testing How a Strategy Would Have Been Run
- BacktestingLook-Ahead Bias: Using Information You Could Not Have Had
- BacktestingSurvivorship Bias: Testing Only on the Winners
- BacktestingTransaction Cost Modelling: The Number That Decides Viability
- BacktestingTrading Performance Metrics: What Each One Hides
Referenced by
Educational use only. This guide explains how a strategy works. It is not investment advice, not a recommendation, and no result described here is a forecast. Test any approach on historical and out-of-sample data, size positions conservatively, and never risk money you cannot afford to lose.