What Is a Backtest? A Plain-English Guide for Trading Bots
A backtest replays a trading bot's rules over past market data and records every trade it would have made. It is the cheapest way to find out whether an idea is worth more of your time. It is also easy to fool yourself with one.
What a good backtest does
- Uses only information available at the time. A signal computed from a bar's close can only trade at the next bar's open. Using the close to trade the same bar is look-ahead bias, and it inflates results.
- Charges real costs. Exchange fees, the spread and slippage you pay on every fill, and funding on perpetual futures. Many strategies that look profitable before costs lose money after them.
- Assumes the worst inside a bar. If a bar touched both your stop and your target, a candle can't tell you which came first, so an honest test assumes the stop hit first.
- Includes coins that died. Testing only coins listed today ignores the ones that were delisted after collapsing. That is survivorship bias.
- Holds data back. See in-sample vs out-of-sample.
What a backtest can't do
It can't predict the future. Markets change, liquidity changes, and your live fills will differ. Read a backtest as evidence, not a promise. A strategy that fails a fair backtest is very unlikely to work live. One that passes still might not.
Numbers worth reading
- Monthly return after costs. This is the headline number. Check that it held up out-of-sample.
- Max drawdown: the worst peak-to-trough loss. Ask yourself whether you could sit through it.
- Number of trades. A great result from 12 trades is mostly luck.
- Profit factor: gross wins divided by gross losses. Anything near 1.0 is break-even and fragile.