A backtest is not the strategy. It is a second implementation of the strategy, written by the same person who wrote the first one, usually later, usually faster, usually with a shortcut. The two will diverge. The only question is whether you find the divergence before it costs you money.
The divergence I found
My tracker exits a trade when price crosses the trailing stop, which after TP1 sits above the entry at peak minus 0.5R. My backtest tested the same rule differently: it triggered the exit when adverse excursion reached the stop distance **below** entry, then credited the result as if the stop had been **above** entry.
Those are two different models. One exits as soon as price falls back to the trailing level. The other lets the trade run far below that level before exiting — but pays it as if it had exited at the level. Trail results in that backtest were flattered.
This is the most common kind of backtest bug, and it is not a coding error in the obvious sense. Every line "looks right". The rule is subtly encoded in two places with two different meanings.
The fix
The simulator and the tracker now call the same function. The exit decision exists once, as a pure function over a path of favourable and adverse excursions in R. The backtest feeds it excursions from cached candles; the live tracker feeds it excursions from one-minute bars. Same code, same ordering (stop before target inside a candle), same gap handling (fill at the open, not at the stop).
Before switching over, I ran twenty thousand random paths through both the old and the new implementation and compared the outputs. They matched exactly. That is the only way I could be confident the refactor did not silently change behaviour — a diff of the code would not have told me anything.
The other places backtests lie
**Costs.** A backtest with zero fees is a wish. Two-sided taker fees plus slippage cost about 0.14% per round trip; on a tight stop that is a large fraction of R.
**Fills.** Assuming you get the close, or the exact stop price, is optimistic. Gaps fill worse. Thin books slip.
**Survivorship.** Testing only symbols that still exist quietly removes the ones that died.
**Regime.** A backtest over a trend period will make any trend-following rule look brilliant. The sample must include the regimes you fear.
The honest conclusion
After unification, the backtest and the ledger tell the same story — and the story is less exciting than the original backtest. That is the point. A backtest you have not reconciled against live behaviour is a marketing document, not evidence.