How to Backtest a Trading Strategy (The Complete Method)
A complete, honest method for backtesting a trading strategy by hand — writing testable rules, choosing a sample, replaying bar by bar, logging trades, and reading the result without fooling yourself.
Most people who say they've backtested a strategy have done something else: they scrolled back on a chart, found some setups that worked, and felt better about trading. That's chart appreciation. It produces confidence without evidence, which is the worst combination there is, because confidence is what makes you size up.
A real backtest is a measurement. It answers one question — if I had followed these exact rules over this period, what would have happened? — and it answers it in a way that could have come out badly. If your testing process can't produce a result you don't like, it isn't testing anything.
This is the complete method, start to finish. It assumes you're testing a discretionary strategy by hand rather than coding an algorithm, because that's what most traders actually have: a setup they can recognise but haven't yet proven.
The six stages
| Stage | What you're doing | You're done when |
|---|---|---|
| 1. Write the rules | Turning your setup into decisions | Someone else could follow it without asking you a question |
| 2. Choose the sample | Picking market, timeframe, period | The window contains conditions you'd hate |
| 3. Replay | Stepping forward bar by bar | You've stopped being able to see the outcome first |
| 4. Log | Recording every setup, taken or not | Rejections and misses are in there too |
| 5. Read the result | Expectancy, not win rate | You know what the number would be under a bad run |
| 6. Validate | Testing rules you didn't fit | It survives data it had no hand in |
Skip stage 1 and everything downstream measures nothing. Skip stage 6 and you've measured your own memory.
Stage 1: Write rules you can actually test
The rule that makes this work: every condition must be answerable from the candles to the left of the bar where you'd act. Not from the move that followed. Not from how it looks now.
"Enter on a strong reaction from the level" fails that test — strong is only knowable afterwards. So does "wait for confirmation," "clean structure," and "price respects the zone." These feel like rules and behave like outcomes. When you test them, you unconsciously grade them with the answer in hand, and your win rate inflates by ten or fifteen points before you've logged a single trade.
Rewrite each one as something a stranger could check:
- Strong reaction → a close back above the level within two candles
- Clean structure → the prior swing high is not broken between setup and entry
- Respects the zone → wick enters, body closes outside
You'll notice this makes your strategy narrower, and that a few setups you'd have taken no longer qualify. That's the point. A rule you can argue with at the time is a rule you'll argue with in the test.
Write the exit rules with the same discipline — where the stop goes, where the target goes, what happens if neither is hit by the session close. Undefined exits are where most hand-testing quietly falls apart, because you end up deciding each one with the benefit of knowing what came next.
Full treatment, including the discretion budget for the calls you genuinely can't articulate: how to write trading rules you can actually backtest.
Stage 2: Choose a sample that can hurt you
Pick one market, one timeframe, one setup. Testing three pairs at once feels efficient and produces a result you can't attribute to anything.
The period matters more than the size at this stage. A window that contains only a clean trend will make almost any trend-following setup look excellent, and you will have learned nothing except that trends trend. You want the periods you'd have hated: the range that chopped, the news week that ran every stop, the quarter where nothing set up at all.
Practical minimums:
- Timeframe: whatever you actually trade. Testing 4H and trading 5m tells you about a different strategy.
- History: enough calendar to contain at least one drawdown. Months, not weeks — a fortnight is one market mood.
- Trades: you're aiming for 100+ before the number means much, and 300+ before you'd size up on it. Don't chase that number yet; get the mechanics right on 30 and then scale.
If you're choosing between 38 markets and unsure which to start with, start with the one you'll trade tomorrow, not the one with the prettiest history. Each class behaves differently under test — US stocks gap every single morning because the data is regular-hours only, and crypto never closes at all, so a rule that assumes a daily reset quietly breaks on both.
Stage 3: Replay it bar by bar
This is the stage that separates a backtest from a story, and it's mechanical rather than clever: you may not see the outcome before you make the decision.
Load the chart at a historical date with everything to the right hidden. Step forward one candle at a time. When your rules trigger, take the trade — mark the entry, the stop and the target at that bar, before advancing. Then keep stepping and let it resolve.
This is also the stage where people quietly give up, because stepping through the empty stretches between setups is where nearly all the hours go. Estimate that before you start rather than discovering it on night three — how long a backtest actually takes does the arithmetic and names the three levers that cut it down.
That constraint does most of the work of the entire method:
- It kills hindsight bias, because there's nothing to be biased by.
- It forces cherry-picking into the open — you have to decide now, not later.
- It shows you the setups you'd have missed while you were asleep, in another trade, or hesitating.
- It puts you through the losing runs in real time, which is the only way to find out whether you'd actually have kept following the rules.
That last one is undervalued. The number your backtest produces assumes you followed the strategy through its worst stretch. Replay is where you find out whether that assumption is true about you.
You can do this by dragging a chart's replay cursor manually, or in a tool built for it — candle-by-candle replay is the whole idea behind CRTLAB, and there's a comparison of the alternatives if you'd rather use something else: TradingView bar replay, Forex Tester, MetaTrader's strategy tester.
Stage 4: Log the trades — including the ones you didn't take
A backtest is only as good as its log, and almost every log is missing the same three things.
Record, for every setup your rules identified:
| Field | Why it's there |
|---|---|
| Date, session, market | Lets you segment later |
| Direction | Long/short bias shows up fast |
| Entry, stop, target | The trade as you'd have placed it |
| Outcome in R | Not dollars — R survives position sizing |
| Taken / skipped / no-fill | The three missing rows |
| Why skipped | Turns a gap into data |
| MFE in R | How far it went your way before it resolved |
R, not dollars. One R is the distance from entry to stop. Recording outcomes in R means a 1% risk and a 3% risk are comparable rows, and it means your results survive any change in account size. Dollar P&L on a hand-tested sample tells you almost nothing.
The skipped rows are the ones nobody keeps, and they're where the honest version of your strategy lives. Every real trader misses setups. A log with a hundred trades and zero misses is describing someone who doesn't exist. Log the miss and the reason — asleep, already in a position, hesitated, rules ambiguous. The last of those is the most valuable thing in the file, because "rules ambiguous" appearing eleven times means stage 1 isn't finished.
MFE — maximum favourable excursion, the furthest the trade went in your favour before it closed — is the field that audits your exits rather than just scoring them. It has a partner, MAE, and a few more fields worth carrying: what to log in a trading journal covers the full set and how to read them. If a third of your losers went 1.5R in profit first, your entry is fine and your target is wrong. Nothing else in the log tells you that.
Stage 5: Read the result properly
Win rate is the number everyone quotes and the number that means least on its own.
Expectancy is the one that matters: the average R you make per trade, across every trade including the losses.
Expectancy = (win rate × average win in R) − (loss rate × average loss in R)
Work an example. A strategy winning 45% of the time at 2.5R:
- 0.45 × 2.5 = 1.125
- 0.55 × 1.0 = 0.55
- Expectancy = +0.575R per trade
Against one winning 60% at 1.4R:
- 0.60 × 1.4 = 0.84
- 0.40 × 1.0 = 0.40
- Expectancy = +0.44R per trade
The second strategy has a much better win rate and makes noticeably less money. This is why "what's your win rate?" is the wrong first question, and why a filter that raises your win rate can lower your edge.
Two more reads worth doing before you trust anything:
Segment it. Win rate by session, by direction, by month. A strategy that's +0.6R in London and −0.1R in New York isn't a strategy with an edge, it's a London strategy you've been diluting. Segmenting is also how you catch stage 2 problems after the fact — if one month carries the whole result, you tested a condition rather than a strategy.
Check the sample can support the claim. With 40 trades, an edgeless strategy produces results this good often enough that you'd be fooled regularly. How many backtests you need covers the arithmetic, and the backtest sample size calculator will tell you how often no-edge would have scored what you scored.
Stage 6: Validate on data you didn't fit
Everything up to here measures how the rules performed on history you've now studied closely. That's in-sample, and it's optimistic by construction — you can't unlearn what you saw while testing.
So: freeze the rules. Don't touch them. Run them over a block of history you haven't looked at, ideally the most recent one, and compare.
If the numbers hold roughly, you have something. If the edge collapses, you fitted the rules to the first sample without noticing — which is extremely common and much better to discover here than with money on it.
Out-of-sample data is single-use. The moment you look at it, study the losses and adjust, it's in-sample forever and you need a fresh block. That discipline is the difference between validating and rationalising. The full procedure — how to split by time, why never randomly, and how to walk forward in blocks by hand — is in out-of-sample testing.
What the number still won't tell you
Even an honest backtest is not a forecast. Four things move between a good test and a live account, and they're all measurable rather than mysterious: costs, fills, data differences, and the trades you skip. The one that surprises people is cost, because its damage is purely a function of stop distance — a 1.5 pip spread is 15% of a 10-pip stop and 1.5% of a 100-pip stop, so tight-stop strategies transfer to live far worse than slow ones. Why backtest results don't match live trading breaks down all four.
And before you conclude the method is broken, check it against the seven ways testing quietly flatters you — 7 backtesting mistakes that make your results worthless includes a twenty-minute audit you can run against the log you just built.
Testing a specific strategy
The method above is strategy-agnostic. If you're testing something specific, the mechanics change at stages 1 and 4 — what counts as a valid setup, and what you need to log:
- How to backtest the CRT strategy — Candle Range Theory, step by step
- How to backtest ICT concepts — the binary decisions the videos never answer
- What is CRT? and what is a fair value gap? if the setup itself is still fuzzy
Start with thirty trades
The most common failure here isn't doing it wrong, it's not starting. Thirty honestly-logged trades on one market with written rules will teach you more than a thousand chart screenshots, and it takes an evening.
You can run the whole method free in CRTLAB: pick one of 38 markets, jump to any date in up to ten years of real history, and replay it candle by candle with your rules written down beside you. No card, no download.
FAQ
How do you backtest a trading strategy step by step? Write rules that can be checked from the candles left of your entry bar; pick one market, one timeframe and a period that includes conditions you'd hate; replay it bar by bar so you never see the outcome before deciding; log every setup including the ones you skipped, in R rather than dollars; read expectancy rather than win rate; then freeze the rules and run them over history you haven't studied. Six stages, in that order — skipping the first makes everything after it meaningless.
How many trades do I need for a backtest to be reliable? Around 100 logged setups before the number is worth discussing, and 300 or more across varied conditions before you'd size up on it. Below about 40 trades an edgeless strategy scores well often enough to fool you regularly. Get the mechanics honest on 30 first, though — a bigger sample collected badly is a more confident wrong answer.
Is manual backtesting better than automated backtesting? They answer different questions. Automated testing is better for mechanical, fully-specified systems where you want thousands of iterations. Manual bar-by-bar replay is better for discretionary strategies, because the thing you're testing includes your own decisions — whether you'd actually take the setup, and whether you'd keep following the rules through a losing run. If your strategy has any judgement in it, an automated test measures a version of it that you don't trade.
How much history should I backtest? Enough calendar to contain at least one drawdown and more than one market condition — months at minimum, years if you're going to trade it seriously. The failure mode isn't testing too little data, it's testing a single regime: a clean trend makes almost any trend-following setup look excellent and teaches you nothing about the range that follows.
What's the difference between backtesting and paper trading? Backtesting is compressed and historical — you can put 200 trades through replay in a weekend. Paper trading is real time, so it tests your patience and execution but produces a sample far too slowly to measure an edge. They're sequential rather than alternatives: backtest to find out whether the edge exists, paper or demo trade to find out whether you can execute it. The full comparison covers where each one misleads you.
Why does my backtest look so much better than my live results? Usually because the test was flattering rather than because live was unlucky. Hindsight, cherry-picked setups, missed trades and untested losing periods all push the result the same direction — up. If your test survives all seven of the common mistakes and live is still worse, the remaining gap comes from costs, fills, data and skipped trades.
Can I backtest a strategy for free? Yes. CRTLAB's free plan gives you 21 of the 38 markets, every tool and every timeframe with two weeks of history on each, which is enough to run the method end to end and build a real sample. The paid plan exists for depth of history — ten years per market — not for features.
Backtest it yourself — free.
Replay real market history candle by candle across 38 markets. No card required.
Start free →Keep reading
How Long Does It Take to Backtest a Strategy?
The honest arithmetic of manual backtesting: why most of the hours go on candles where nothing happens, and the three levers that actually cut them down.
What to Log in a Trading Journal (The Fields That Actually Change Anything)
Most trading journals record what happened and change nothing. The fields that actually improve your trading — R, MFE, MAE, skipped setups, rule adherence — and how to read them.
How to Write Trading Rules You Can Actually Backtest
Most trading rules can't be tested because they aren't rules. Here's how to write a strategy so precisely that a stranger could replay your week and take the same trades.