Backtesting your trades
Day 20 of 26 · 11 min read · By DT Terminal
Picks up fromDay 19 · Managing risk in the strategy
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 tick by tick 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 the strategy you wrote this week would have made money, before you trust it 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.
- Trading live. Nobody hesitates on a replay or moves a stop out of fear.
Go deeper
By now you have a whole strategy: the entry model with its stop and target, the volume filter and the golden zone as optional versions, the management rules, 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. Here is the model from Day 15, rule by rule:
| 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 |
| Buy after the stops get run | An M15 wick trades below the equal lows, and that candle closes back above them |
| Wait for the turn | An M15 body then closes above the last lower high |
| Enter on the pullback | A buy limit at the top edge of the gap the shift left |
| Put the stop somewhere safe | Stop 2 pips below the sweep low. Skip the trade if that is more than 30 pips |
| Take profit when it looks done | Target the next high, and only if it is at least 2R away. 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 test well: 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. Pick the strategy on the backtester's order ticket and its rules show under Rules followed, so every trade records which ones it met.
Replay tick by tick, 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 ChartsEURUSD · M15Replay pausedYour model says buy: a buy limit at 1.08800, stop 1.08640, target 1.09200. Press play. Then replay the same setups with the stop moved to breakeven, and compare the R.
Record every trade, 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, the sweep, the shift and the gap have all closed, and price has not come back to the gap yet. The stop sits 2 pips below the sweep low and the target at the old high, which is at least 2R away. Record the ones you would rather forget too: a record that changes shape halfway through cannot be added up. Replaying the same setups under each management rule, hold or breakeven, is how you find which one your own trades favour.
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 More settings, 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 and quiet over many. The likely range of a measured 40% win rate:
| 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 the average 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 tick by tick.
- 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 |
| Paper or 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 practice 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 live sample is still small, the market has changed, the edge was never there, or your execution differs. Your record tells you which. Practice in real time is covered in Day 7.
This is where your own record earns its place. Put your practice stats next to your real-money ones: your numbers show whether an edge 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