Backtesting your trades
Day 20 of 26 · 11 min read · By DT Terminal
A backtest tells you whether your rules would have made money before you risk any. This lesson covers writing rules precise enough to test, replaying the chart bar by bar without looking ahead, how many trades to trust, the stats to read, the traps that make a backtest lie, and the path from backtest to demo to live.
Unlock the full lesson in the app
Worked examples, the quiz and the interactive tools are in the app. Free account.
What backtesting is, and what it is not
Backtesting finds out whether your rules would have made money, before you trust them with any. Go back to a past date, hide everything after it, and step through one candle at a time, taking and writing down every trade your rules allow.
A backtest is not:
- A forecast. It shows how the rules behaved on the past you tested.
- A search for perfect settings. Tweak until last year looks flawless and you have described last year, not found an edge.
- Trading live. Nobody hesitates on a replay or moves a stop out of fear.
Go deeper
By now you have the pieces of a strategy: the structure, the zones, the entry, the stop and the target, and a risk plan around it. In a backtest you take every trade exactly as you would live.
Markets change, so a result is an estimate, not a promise. And nobody skips a trade after three losses on a replay. Those habits are real, and only demo and live trading test them. The backtest cannot tell you whether you will follow the rules; it tells you which rules are worth following in the first place.
Rules precise enough to test
A rule is testable when two people reading it would take the same trades, at the same prices, on the same chart. If it needs a decision in the moment, you are testing your mood. Rewrite each rule until nothing is left to decide:
| Vague | Testable |
|---|---|
| Buy when the trend is up | Long only after H4 makes a higher high and a higher low, while price holds above that higher low |
| Enter on a pullback | Enter at the close of the first H1 candle back above the broken high |
| Put the stop somewhere safe | Stop 2 pips below the pullback low. Skip the trade if that is more than 30 pips |
| Take profit when it looks done | Target 2R. No early exit, no moving the target |
| Avoid the news | No new trade from 15 minutes before to 15 minutes after a high-impact release for either currency |
| Do not overtrade | At most 2 trades a day, and stop after 2 losses |
The structure in Day 10 and the news times in Day 6 make good testable rules: a point on the chart, or a time on the calendar.
Write the rules in Strategies first
Go deeper
A strategy's Rulebook has three phases: Before the trade holds the entry criteria, In the trade holds the stop, the target and how you manage it, and After holds what happens once it closes. Write each rule as something you could point at on a chart. Linking the strategy to a backtest session commits you to its criteria before the bars start moving.
Replay bar by bar, and record every trade
Bar replay shows the chart up to a point in the past, then reveals one candle at a time, so you decide with only what you could have seen. Scrolling a finished chart is not a backtest: your eye finds the winners and slides past the losers.

DT Terminal ChartsXAUUSD · H1Replay pausedThe rules say go long: entry 2343.50, stop 2334.00 below the pullback low, target 2362.50 at 2R. Place both levels and press play.
Record every trade, the losers and skipped setups too, with the same fields:
| Field | Why it is there |
|---|---|
| Date, time and instrument | To find it again, and to see which sessions and markets carry the edge |
| Entry, stop and target | To check the trade matched the rules, and to work out the R |
| Result in R | The one number every stat is built from, the same on any account size |
| Followed the rules: yes or no | Separates what the strategy did from what you did |
| Screenshot and a one line note | To review the setup later, with what you saw at the time |
Replay it in the backtester
More on the replay and the record
In the frame above, price pulled back from a swing high and closed back up. The target sits just under the swing high. Record the ones you would rather forget too: a record that changes shape halfway through cannot be added up.
In the backtester, a session needs an instrument, a start date and a starting balance. The 1y to 5y buttons and Surprise me pick the start date for you, so you cannot choose a stretch you remember. Set your risk per trade, commission and spread under Customize, then play with Space or step one candle with the arrow keys. After L or S, drag the stop and target into place, with economic news marked on the chart. Every trade is recorded in the session, and P drops a note while C saves a screenshot.
How many trades before you trust it
As Day 9 showed, a handful of trades tells you almost nothing: luck is loud over a few trades and quiet over many. The likely range of a measured 40% win rate, by sample size:
| Trades in the sample | Margin, roughly | Likely true win rate |
|---|---|---|
| 10 | 26.0 pts | 17% to 69% |
| 20 | 19.7 pts | 22% to 61% |
| 50 | 13.1 pts | 28% to 54% |
| 100 | 9.4 pts | 31% to 50% |
| 200 | 6.7 pts | 33% to 47% |
| 500 | 4.3 pts | 36% to 44% |
Worked example
Example 01: Is a 50% win rate at 1:1.5 an edge?
The worked example, with every number walked through, is in the app.
Go deeper
These are common rules of thumb, not magic numbers. A win rate close to breakeven needs a big sample before the two can be told apart.
The stats to read
Once the sample is big enough, a few numbers describe it. Each answers a different question:
| Stat | How it is worked out | What it tells you |
|---|---|---|
| Win rate | Wins divided by wins plus losses | How often the rules are right. Meaningless without the size of the wins and losses |
| Average win and loss | The mean of the winners, and of the losers, in R | The reward to risk you actually got, not the one you planned |
| Expectancy | Total R divided by the number of trades | What one trade is worth on average. Above zero after costs is an edge |
| Profit factor | All the winning R divided by all the losing R | How much the winners outweigh the losers. Above 1 makes money |
| Max drawdown | The biggest fall from a peak in the running total | The worst stretch you would have had to sit through. Size your risk for it |
| Longest losing run | The most losses in a row | What your nerve and your daily limits must survive |
| Number of trades | A count | How far to trust every number above it |
Worked example
Example 02: Ten trades, worked by hand
The worked example, with every number walked through, is in the app.
Interactive tool
Backtest stats calculator
This interactive tool runs in the app, with your own numbers.
The running total, and the three samples
No one of these stats is enough alone.
The running total goes 0, 2, 1, 0, −1, 1.5, 1.5, 0.5, 2.5, 1.5, 3.5. From the peak of 2 after trade 1 it falls to −1 after trade 4: a max drawdown of −3R, which is also the longest losing run, 3 in a row. The arithmetic is the same at 100 trades, and the calculator does it for any list.
Try the three samples. The 30 trades at 1:2 sample wins under half the time and still earns about a quarter of an R a trade. High win rate wins more than three trades in four and earns less, because each win is less than half the size of each loss. Only 5 trades looks better than both, which is exactly why five trades are not a result.
The traps that make a backtest lie
A backtest can be honest arithmetic on a dishonest test:
- Curve fitting. Adding a filter for every losing stretch. Change one thing at a time.
- Cherry picking. Testing the months you remember, or skipping setups. Take every trade the rules allow.
- Looking ahead. Peeking right, or replaying a week you have seen. Decide on closed candles.
- Ignoring costs. Spread and commission can wipe out a thin edge. Put them in the test.
- Ignoring the news. A fill just before a major release is a different trade.
- One kind of market. Test quiet, ranging and fast months, not just a trend.
Go deeper
- Curve fitting: each tweak fits the noise of that stretch. Test the change on a stretch of data you have not used yet.
- Cherry picking: testing the months you remember trending nicely, or quietly skipping a setup that "did not look right". Let something else pick the start date.
- Looking ahead: glancing at the right side of the chart. Replay bar by bar.
- Costs come off every trade, winners and losers.
- News: a setup that fills a minute before a major release has wider spreads and slippage. Test it the way your rules say you would trade it, or skip it the way your rules say you would.
- One kind of market: three months of a strong trend tells you how the rules do in a trend. Test across quiet months, ranging months and fast ones before you call it an edge.
Keep the old sample as it was, and let the new rules earn their own.
From backtest to demo to live
A good backtest earns the next step, not real money. Each stage tests something the last could not:
| Stage | What it tests | Move on when |
|---|---|---|
| Backtest | Whether the rules have an edge on past data | At least 50 to 100 trades, a positive expectancy after costs, and a drawdown you could live with |
| Demo | Whether you can follow the rules in real time, with live spreads, news and no fast forward | Several weeks of trades by the rules, with results in the same range as the backtest |
| Live, small size | Whether you still follow them when the money is real | The live record matches the demo one. Then raise size slowly |
Expect live results a little below the backtest: worse fills, missed trades, hesitation. A small drop is normal. A large one means the edge was never there, or your execution differs from your rules. Demo is covered in Day 7.
This is where a verified record earns its place. Put your practice stats next to your real-money ones: an edge either holds live or decays.
Go deeper
A large drop is information. If the edge was never there, a bigger sample would have shown it. If your execution differs from your rules, your record will show it.
Keep backtests apart from your real P&L, and compare the two instrument by instrument: win rate, profit factor and expectancy from practice next to the same figures from real money.
Check yourself
Quick review · 0 of 0