Backtesting means taking the rule you wrote, replaying it against past prices, and recording every trade it would have made. It is the cheapest test in trading: killing a bad idea in a backtest costs nothing, while killing the same idea live costs real money. The catch is that a careless backtest does the opposite of its job, and builds confidence in ideas that never worked. This guide covers both sides: how to run one, and how to avoid fooling yourself.

What is backtesting, exactly?

A small character rewinding a reel-to-reel tape player, pulling the tape back to replay it

A backtest asks one question: if this exact rule had been running in the past, what would have happened? You give it three ingredients. Historical prices, usually candles. The rule, written precisely. And the costs: fees on every trade, plus the spread, the small gap between the buy and sell price, that you pay when you trade.

The output is a list of trades and totals built from them: profit or loss, the number of wins and losses, and the worst losing stretch along the way (the drawdown). That last number deserves special attention, because it is what you would have had to sit through without knowing the recovery was coming.

How does a backtest actually work?

A character stepping along a row of floor tiles one at a time toward an open door

Walk through it with the rule from earlier in this series: buy $100 of BTC when the price falls 3% below its 24-hour average, sell when it returns to the average.

The backtest steps through history one candle at a time, pretending each candle is “now.” At each step it computes the 24-hour average using only the candles before that moment, checks whether the price sits 3% below it, and if so records a buy at the next available price and charges the fee on it. Then it keeps stepping until the sell condition fires and records the exit the same way, price minus fees. Repeat over a year of candles and you have a trade list: every entry, every exit, every cost.

The phrase “only the candles before that moment” is the entire craft of backtesting. The moment your rule accidentally sees the future, even by one candle, the results become fiction.

Why do backtests lie?

A character filing a wavy key so that it fits one particular lock

Four traps produce almost all of the fiction.

Peeking at the future. Using today’s close to decide a trade made this morning, or computing an average that includes the candle you are trading on. It sounds obvious and it happens constantly, usually by accident.

Overfitting. Tune a rule long enough against one stretch of history and it will fit that history perfectly, the way a key fits one lock. The past is the lock; the future is a different lock. If you tried twenty variations and kept the best, the best is mostly luck that looks like skill.

Ignoring costs. Fees and spread turn many mildly profitable rules into steady losers. Every backtest should charge itself the real fee schedule and a realistic spread on every single trade.

Testing one lucky era. A rule tested only on a rising year has learned one lesson: buy. Test across different conditions, rising, falling, and sideways, before believing anything.

Each trap has its own defenses, and a separate guide in this series covers them in working detail. For a first backtest, honestly charging costs and never letting the rule see the future removes most of the danger.

Is backtesting even accurate?

A character shaking a sieve that holds back dark lumps while colored balls fall through, with an unused crystal ball beside it

No, and it is important to understand exactly what that means. A backtest is not a prediction of future profit. It is a filter. A bad backtest result is strong evidence, and it saves you real money by killing the idea. A good backtest result is weak evidence, and it earns the idea exactly one thing: the right to be tested forward with fake money.

Markets change, past patterns dissolve, and a strategy that genuinely worked for three years can stop working the month you start running it. Backtesting cannot protect you from that. What it can do is guarantee you never fund an idea that failed even in the friendliest possible test: its own past.

How much backtesting is enough?

A toy car driving a loop track that passes through spring, summer, autumn, and winter

Measure in conditions and trades, not in months. A useful backtest covers at least one rising market, one falling market, and one boring sideways stretch, with enough trades in total that luck stops being the main explanation, a few dozen at minimum. A rule that traded eight times in two years is an anecdote regardless of how good the eight look.

There is also a stopping point. Once the rule has been tested honestly across conditions, more replaying of the same history adds nothing except the temptation to tune. Tuning until the past looks beautiful is the overfitting trap from above, approached from the other direction.

Backtesting, paper trading, forward testing: what order?

A three-stage funnel: many colored balls at the top, fewer in the middle, a single ball dropping out at the bottom

They are stages of one funnel, and two of the names mean the same thing. The order matters.

Backtesting replays the past, and filters out ideas that never worked.

Forward testing, also called paper trading, runs the surviving rule in real time with fake money. This is where you discover the things history cannot show: orders that would not have filled, data that arrives late, the gap between the price your rule saw and the price you would have gotten.

Live trading at small size is the final stage, and the only stage where the results are real. The funnel exists to make sure that whatever reaches this expensive stage has already survived everything cheaper.

The build guide in this series places these stages in the full path from nothing to a running bot, and the complete guide maps all eight steps. The next guide covers order execution: what actually happens between your bot’s decision and a filled trade.

FAQ

What is the best backtesting software?

For a simple rule, a short script you wrote yourself is hard to beat, because you know exactly what it assumes. Chart platforms with built-in strategy testers are a reasonable no-code start. Judge any tool on whether it lets you include fees and spread, control what data the rule can see, and export the trade list for inspection.

Can you backtest without coding?

Yes. Several charting platforms include visual strategy testers, and they are fine for a first pass. The trade-off is control: it is harder to verify what the tester assumes about fills, fees, and timing, and those assumptions are exactly where backtests go wrong.

How many trades does a backtest need?

Enough that luck stops being the main explanation. A rule that traded twelve times in a year tells you almost nothing. As a rough floor, look for at least a few dozen trades across different market conditions, and treat anything under that as an anecdote, not a result.