Backtesting a Trading Strategy Before You Risk Real Money
A step-by-step process for backtesting any trading strategy properly — including the mistakes that make backtests lie to you and how to avoid them.
Every trading strategy sounds good in your head. Backtesting is how you find out whether it actually holds up against real market data — before you find out the expensive way, with real money on the line.
Done properly, backtesting tells you a strategy's approximate win rate, expectancy, and drawdown characteristics. Done poorly, it tells you whatever you wanted to hear. This guide walks through the process end to end, and — more importantly — the specific mistakes that make backtests systematically lie to traders.
What backtesting actually proves (and doesn't)
A backtest answers one narrow question: if this exact rule set had been applied to this historical data, what would have happened? It does not prove the strategy will work going forward — markets change, and a backtest can't account for a regime shift that hasn't happened yet. What it does give you is:
- A rough sense of whether the strategy has positive expectancy at all
- An estimate of win rate, average win/loss size, and max drawdown
- A way to catch obviously broken rules before risking capital
- A baseline to compare your live results against later
Treat it as a filter for bad ideas, not a guarantee for good ones.
Step 1: Write the rules down precisely
Before you look at a single chart, write your entry rule, exit rule, stop-loss rule, and position-sizing rule in plain language — precise enough that someone else could follow them without asking you a clarifying question.
"Buy breakouts" is not a rule. "Enter long when price closes above the prior 20-day high on volume at least 1.5x the 20-day average volume; stop at the low of the breakout day; target 2x the initial risk" is a rule. If you can't write it this precisely, you don't have a strategy yet — you have an idea, and backtesting an idea just produces noise.
Step 2: Choose a representative data set
Pick a date range long enough to include multiple market conditions — at least one trending period, one choppy/range-bound period, and ideally one high-volatility period. A strategy backtested only across a strong bull run will look far better than it deserves to.
A common trap: testing only on the instrument and time period where you first noticed the pattern. If you spotted the setup on a chart of a stock that ran hard last year, testing exclusively on that stock's data over that exact period all but guarantees an inflated result — you cherry-picked the sample before you started.
Step 3: Apply the rules mechanically, trade by trade
Whether you're doing this by hand (scrolling through historical charts one trade at a time) or with backtesting software, the discipline is the same: apply the rule exactly as written, in order, without adjusting it mid-test because a particular trade "should" have worked differently. If you find yourself skipping a signal because you "know" it didn't work out, you've stopped backtesting and started overfitting.
Log every trade the same way you'd log a live trade: entry, exit, size, stop distance, and result in R-multiples (see our guide to trading journal metrics for why R-multiple is the right unit here, not raw dollars).
Step 4: Calculate the numbers that matter
Once you have 30-50+ historical trades logged, calculate:
- Win rate — percentage of trades that were profitable
- Average win (R) and average loss (R)
- Expectancy — (win rate × average win) − (loss rate × average loss), expressed in R
- Max drawdown — the largest peak-to-trough equity decline across the test
- Longest losing streak — how many consecutive losses did the strategy produce
A strategy can have a mediocre win rate (40%) and still be strongly profitable if average wins are large relative to average losses. It can also have a great win rate (70%) and still lose money if losses are disproportionately large. Expectancy is the number that actually tells you whether the strategy makes sense — not win rate alone.
The five mistakes that make backtests lie
1. Lookahead bias
Using information in a trade decision that wouldn't have been available at the time. The classic example: testing a strategy against a stock's current index membership, when the stock was actually added to that index later — meaning you're testing with information you couldn't have had in the past. Any time your test "knows" something about the future relative to the trade date, the result is invalid.
2. Survivorship bias
Testing only on instruments that still exist today ignores everything that got delisted, went bankrupt, or was acquired — which were disproportionately the bad outcomes. A strategy tested only on today's S&P 500 constituents, applied retroactively, silently excludes every company that failed and dropped out of the index. That inflates the results.
3. Overfitting to the test data
If you keep tweaking parameters (moving the moving-average length from 20 to 23 to 27 because each adjustment improves the historical result) until the backtest looks great, you've fit the strategy to noise in that specific data set, not found a real edge. A strategy that needs its parameters tuned to three significant figures to be profitable almost never survives contact with new data.
4. Ignoring transaction costs and slippage
Commissions, spread, and slippage (the difference between your intended entry price and your actual fill) eat into every trade. A strategy that looks profitable on paper with zero costs assumed can be a loser once realistic costs are applied — especially high-frequency or small-edge strategies where costs are a large fraction of the average trade result.
5. Small sample size
Ten trades isn't a backtest, it's an anecdote. Random variance dominates at that sample size — you could easily get a great-looking (or terrible-looking) ten-trade sequence from a strategy with genuinely mediocre long-run expectancy. Aim for at least 30-50 trades before drawing any conclusion, and treat even that as a preliminary read rather than a final verdict.
Turn your backtest into a live playbook
Once a strategy passes backtesting, TradeLens lets you tag every live trade against it — so you can see immediately whether real performance is tracking your backtest or drifting from it.
Step 5: Forward-test before going live with full size
A backtest that survives all five traps above is a reasonable candidate — not a guarantee. The next step is forward-testing: trading the strategy in real time, either on a small live size or in a simulated account, for enough trades to confirm the edge holds up outside the historical sample it was built on. Only after that should you scale up to normal position sizing.
Backtesting is a filter, not a crystal ball. Used honestly — precise rules, representative data, and awareness of the biases above — it will save you from taking a lot of bad ideas live. Used carelessly, it will just give you false confidence in whatever you already wanted to believe.