Skip to content
GetProfitable
Search
Dictionary

Backtesting

Testing a set of trading rules on historical data to see how it would have performed.

A backtest turns an idea into numbers: win-rate, expectancy, max-drawdown, profit-factor. Done honestly, it kills bad ideas cheaply. Done badly, it produces beautiful curves that fail live.

The usual sins are curve fitting (tuning parameters until the past looks perfect), ignoring slippage and commissions, using data that was not available at the time, and survivorship-bias in the stock universe.

Example: a strategy backtests at +0.5R per trade. Adding realistic 0.1R of slippage and commissions per trade cuts it to +0.4R. Adding the stocks that were delisted during the period cuts it to +0.2R.

Related: paper-trading, expectancy, max-drawdown, survivorship-bias, sample-size

See it drawn

Original diagrams for the ideas on this page. Illustrative, not real market data.

The spread of outcomes behind an expectancyA histogram of forty trades: a tall block of small losses on the left, a low spread of larger wins on the right, and a line marking the average outcome.NUMBER OF TRADES051024 LOSSES, AVG −$20016 WINS, AVG +$600EXPECTANCY +$120−$400−$200$0+$200+$400+$600+$800PROFIT OR LOSS PER TRADEexpectancy = (40% × $600) − (60% × $200) = +$120 per trade
Expectancy: the average trade. Forty trades sorted by outcome: 24 small losses and 16 larger wins. Weighting each side by how often it happens gives the average result per trade, marked here by the dashed line at +$120.
Slippage on a market orderA buy order clears four price levels, so the average price paid is worse than the price first quoted.Buy 1,000 shares at marketpricesell orders resting (bar length = size)20.04300 shares20.03200 shares20.01200 shares20.00300 sharesnothing resting at 20.02order sweeps up the bookaverage fill 20.02SLIPPAGE0.02 a share$20.00 in totalintended 20.00Each level fills at its own price; the average is what you really paid.
Slippage on a market order. You click at 20.00, but only 300 shares are resting there, so the rest of the order fills at 20.01, 20.03 and 20.04. The average price paid is 20.02, and that two-cent gap is slippage.

Educational only, not advice. Spotted an error? Post in Site Feedback.