Sam's table from Lesson 79 had 10 trades in it, and he knew ten trades couldn't prove anything. Waiting for 50 more live ones would take months of mornings, and every one of them would cost real money to learn from.
But here's the thing about the market: it keeps a diary. Every candle from the last few months was still sitting on his charts, waiting to be read.
So on Saturday morning he opened a spreadsheet, typed his PullbackA pullback is a temporary counter-trend price movement within an established trend — in an uptrend, a pullback is a short-term decline that offers a lower-risk entry point before the trend resumes, as opposed to a reversal which signals theRead definition → rules from Lesson 77 across the top and started stepping through old charts one candle at a time. By Sunday night he had 50 trades and one uncomfortable discovery. We'll get to that.
In 30 seconds
- BacktestingThe process of running a defined trading strategy against historical price data to evaluate how it would have performed before risking real capital. A well-constructed backtest gives you a statistical baseline — win rate, profit factor, maxRead definition → means applying a strategy's exact rules to past price data to see how it would have performed, before you risk money on it.
- You can backtest by hand: write precise rules, pick a fair sample, step through charts candle by candle with replay mode and record every trade in a spreadsheet.
- Track the Win RateWin rate is the percentage of your trades that result in a profit — calculated as (number of winning trades ÷ total trades) × 100 — and while commonly cited as a measure of trading success, it means very little without also knowing the averRead definition →, the average win and loss in R, ExpectancyExpectancy is the average amount your strategy makes or loses per dollar risked — it's the single best number for evaluating whether your trading approach has a real mathematical edge.Read definition →, the longest losing streak and costs.
- The biggest dangers are seeing the future (look-ahead bias), tweaking rules until the past looks great (overfitting) and ignoring costs. A good-looking backtest is a reason for more testing, not for going live.
In this lesson you'll learn what backtesting is, a five-step manual method that needs no code, what to record, which numbers matter, how easily a backtest can lie (DayTradingToolkit simulated it) and what Sam's 50-trade backtest showed. It builds on Lesson 56: Win Rate vs. Risk/Reward and Lesson 74: Your First Trading Plan.
What is backtesting?
Backtesting is the process of applying a trading strategy's rules to historical price data to see how the strategy would have performed if you'd traded it in the past.
Think of a flight simulator. A pilot crashes a hundred times on the ground so they never have to crash in the air. A backtest lets your rules "crash" on past charts, so you find out where they break while it only costs you an evening.
A backtest isn't a prediction, though. It tells you how your rules would have done during one stretch of the past, under the conditions of that time. Treat it as a filter that removes bad ideas, not a certificate that proves good ones.
Why backtest before you trade?
Backtesting shows you whether a set of rules has any chance of working, how often it loses and how deep its losing streaks run, in days instead of months.
It does three other jobs that beginners don't expect:
- It forces your rules to be exact. "Buy a strong pullback" can't be tested. "Buy the first 5-minute close above the 9 EMA after a pullback that holds the prior swing low, on lighter VolumeVolume is the total number of shares (or contracts) traded during a given time period — it's the primary confirmation tool for all price action, because a price move accompanied by high volume indicates genuine market participation, while tRead definition →" can.
- It trains your eyes. After 50 setups you start to see the difference between a clean one and a sloppy one before the candle finishes.
- It pre-loads your nerves. If your backtest contains a streak of five losses in a row, then five in a row in live trading is a known event, not a crisis. Lesson 72 shows what happens when it's a surprise.
How do you backtest manually, step by step?
A manual backtest takes five steps: write exact rules, pick a fair sample, replay the charts, record every trade and analyze the results.
Step 1: Write rules a stranger could follow
Write the entry trigger, the stop, the target, the position size and the conditions under which you skip a trade. Here's the test: if two people could read your rules and take different trades, the rules aren't exact yet.
Keep the rules few. A rule of thumb is three to five entry conditions. Each extra condition is another place for the test to quietly fit itself to the past.
Step 2: Pick a fair sample
Choose your stocks and your dates before you look at a single trade. Include different kinds of days: trend days, range days and big news days (Lesson 79 shows how to label them). If your sample is one strong month, your result is a result about that month.
Step 3: Replay candle by candle
Most charting platforms have a bar replay mode: you pick a past starting point and step forward one bar at a time. TradingView's replay lets you press "Forward" to advance a step or play at an adjustable speed, though how much intraday history you can replay depends on your plan and the symbol (TradingView Support). If your platform has no replay, cover the right side of your screen with a sheet of paper and scroll slowly. It looks silly, and it works.
At each candle, decide with only what was visible then. If the setup matches every rule, log it. If it matches most of them, skip it. No "it would have worked."
Step 4: Record every trade
Log each trade the moment you take it in the replay, including the ones you'd rather forget. Here's what one row might look like:
- Column
- Trade number, date, stock
- Example
- #14, HIJK
- Column
- Day type (from Lesson 79)
- Example
- Trend
- Column
- Entry, stop, target
- Example
- $31.40, $31.08, $31.95
- Column
- Exit and reason
- Example
- $31.95, target hit
- Column
- Result in R, after costs
- Example
- +1.6R
- Column
- Notes
- Example
- Volume lighter on the dip
| Column | Example |
|---|---|
| Trade number, date, stock | #14, HIJK |
| Day type (from Lesson 79) | Trend |
| Entry, stop, target | $31.40, $31.08, $31.95 |
| Exit and reason | $31.95, target hit |
| Result in R, after costs | +1.6R |
| Notes | Volume lighter on the dip |
Record results in R (your planned risk as one unit), so the test doesn't depend on how many shares you'd have bought. In that row, the risk was $0.32 and the reward was $0.55, which is +1.72R before costs and +1.6R after about two cents per share of slippage and the spread. Deduct a realistic estimate of costs on every trade, because costs are the first thing that disappears from a backtest and the first thing that shows up in real trading.
Step 5: Analyze the results
Once all the trades are in, calculate:
- Win rate: wins divided by total trades.
- Average win and average loss, in R.
- Expectancy: the average result per trade, in R. The formula is (win rate × average win) minus (loss rate × average loss). If you win 45% of the time, your average win is +2.1R and your average loss is 1R, expectancy is (0.45 × 2.1) − (0.55 × 1.0) = +0.395R per trade (Lesson 56 has the full story).
- Profit factor: total wins divided by total losses. Above 1.0 means the test made money.
- Longest losing streak and largest drawdown: the worst stretch you'd have lived through, so you can decide whether you could live through it.
- Results by day type: many strategies work on trend days and lose on range days. That's not a flaw. It tells you when to trade and when to sit out.
How easily can a backtest lie?
Easily, and usually in your favor, which is exactly why it's dangerous. Here are the biases to build your test around.
- Look-ahead bias. Using information you couldn't have had at the time, such as judging a morning trade by how the afternoon turned out. Replay mode is the cure.
- Overfitting. Adjusting the rules until they fit the past perfectly. This one needs a closer look, below.
- Selection bias and survivorship bias. Testing only the charts you remember working, or only stocks that are still trading today, so the failures never make it into your sample.
- Ignoring costs. Small per-trade costs add up across hundreds of trades, as the table later in this lesson shows.
How does overfitting happen?
Overfitting happens when you keep adjusting rules after seeing results, so the strategy learns the noise in your sample instead of a real pattern. It sneaks in one reasonable-sounding tweak at a time: "Let me skip Mondays." "Let me raise the volume filter." Each one makes the past look better.
DayTradingToolkit simulated how powerful this is. DayTradingToolkit created rule variations that have no edge at all (they win 33% of the time with 2R winners and 1R losers, so the true expectancy is exactly zero). For each run, the simulation tested N variations on 50 trades each, picked the one that looked best, and then tested that winner on 50 brand-new trades. That was repeated 4,000 times.
- Variations tried
- 1
- Average result of the best one
- 0.00R
- Share of runs where the best looked like +0.16R or better
- 18.8%
- Average result on fresh trades
- 0.00R
- Variations tried
- 5
- Average result of the best one
- +0.23R
- Share of runs where the best looked like +0.16R or better
- 66.0%
- Average result on fresh trades
- 0.00R
- Variations tried
- 20
- Average result of the best one
- +0.38R
- Share of runs where the best looked like +0.16R or better
- 98.8%
- Average result on fresh trades
- 0.00R
- Variations tried
- 100
- Average result of the best one
- +0.51R
- Share of runs where the best looked like +0.16R or better
- 100%
- Average result on fresh trades
- 0.00R
- Variations tried
- 500
- Average result of the best one
- +0.63R
- Share of runs where the best looked like +0.16R or better
- 100%
- Average result on fresh trades
- 0.00R
| Variations tried | Average result of the best one | Share of runs where the best looked like +0.16R or better | Average result on fresh trades |
|---|---|---|---|
| 1 | 0.00R | 18.8% | 0.00R |
| 5 | +0.23R | 66.0% | 0.00R |
| 20 | +0.38R | 98.8% | 0.00R |
| 100 | +0.51R | 100% | 0.00R |
| 500 | +0.63R | 100% | 0.00R |
DayTradingToolkit simulation: 4,000 runs per row, 50 trades per test, fixed seed, independent variations. Not real market data.
Read that table twice. Even a rule with a true edge of zero showed +0.16R or better in about one 50-trade test out of five. Try 20 variations and the best of them almost always looks like a winner, and then it falls back to nothing on new data. (In real life, variations of one rule on the same charts are correlated, so the inflation is smaller, but it points the same way.)
Researchers have put numbers on this. Bailey, Borwein, López de Prado and Zhu showed that with only five years of daily data, no more than about 45 variations of a strategy should be tried before the best one is likely to look good by chance alone. And a paper by Sullivan, Timmermann and White built a bootstrap method to adjust for this "data snooping" on the same rules Brock, Lakonishok and LeBaron had studied, using 100 years of Dow Jones data.
Real edges also shrink once they leave the lab. A study of 97 stock-return predictors found average monthly returns of 0.582% in the original samples, 0.402% in the out-of-sample period before publication and 0.264% after publication (McLean and Pontiff, 2016, summarized by the CFA Institute). That's about stock factors, not day trading, but the lesson carries over: expect the live version of anything to be weaker than the backtest.
What's the defense?
What do costs do to a backtest?
- Extra cost per trade, in R
- 0
- Expectancy that remains
- +0.16R
- Extra cost per trade, in R
- 0.05R
- Expectancy that remains
- +0.11R
- Extra cost per trade, in R
- 0.10R
- Expectancy that remains
- +0.06R
- Extra cost per trade, in R
- 0.16R
- Expectancy that remains
- 0.00R
| Extra cost per trade, in R | Expectancy that remains |
|---|---|
| 0 | +0.16R |
| 0.05R | +0.11R |
| 0.10R | +0.06R |
| 0.16R | 0.00R |
Simple arithmetic on Sam's hypothetical backtest result.
A thin edge can vanish into a cost you never put in the spreadsheet. That's why a modest, honestly costed backtest beats a spectacular one.
How many trades is enough?
More than you think. Fifty trades is a decent first pass, but it can't tell you whether a small edge is real. DayTradingToolkit's simulation shows why: a rule with no edge at all scored +0.16R or better on 50 trades about 20% of the time, and the typical swing from luck alone (one standard deviation) was about 0.20R. Lesson 81 takes this on directly.
What about backtesting software?
Software can test rules on far more data, much faster, but it comes with its own limits, and you still need exact rules and a clear idea of what the tool includes and leaves out.
Disclosure: This lesson contains affiliate links. If you buy through them, DayTradingToolkit may earn a commission at no extra cost to you.
Trade Ideas, this guide's top pick for an all-in-one active trading platform, includes a backtesting tool called OddsMaker that tests scanner-based strategies without code. It has real limits: it works from 1-minute candles, doesn't model the spread and covers a limited window of recent history, so it's best for screening ideas, not proving them. The OddsMaker review explains what it can and can't do, and you can explore Trade Ideas here.
A manual backtest is slower, but it trains your eye on exactly the charts you'll be trading, and it doesn't need a subscription.
Sam's 50-trade backtest
Sam tested his pullback rules on 50 past setups from his watchlist over the previous three months. All figures are hypothetical, in R, with costs deducted.
- Measure
- Trades
- Result
- 50
- Measure
- Wins
- Result
- 21 (42%)
- Measure
- Average win
- Result
- +1.84R
- Measure
- Average loss
- Result
- −1.06R
- Measure
- Expectancy
- Result
- +0.16R per trade
- Measure
- Profit factor
- Result
- 1.26
- Measure
- Total
- Result
- +7.93R
- Measure
- Longest losing streak
- Result
- 5
| Measure | Result |
|---|---|
| Trades | 50 |
| Wins | 21 (42%) |
| Average win | +1.84R |
| Average loss | −1.06R |
| Expectancy | +0.16R per trade |
| Profit factor | 1.26 |
| Total | +7.93R |
| Longest losing streak | 5 |
Sam's backtest expectancy (hypothetical)
(The averages are rounded, which is why 38.64R minus 30.74R gives 7.90R, a hair under the exact +7.93R in his log.)
His average loss ran above 1R because of slippage and costs. His average win came in under the 2R he usually aimed for, because some trades exited early on his rules. At his $27 risk, +0.16R works out to about $4.30 per trade. It looked encouraging.
Then he noticed something uncomfortable. After a run of losses in his second month, he'd raised his volume filter and carried on, so the final 50 trades weren't tested on one fixed set of rules. That's the first step of overfitting, and the table above shows how little it takes. He wrote down the rule as final, set aside the most recent month and didn't touch it.
Myth vs. fact
Myth and fact
Mistake and fix
Tweaking the rules after every loss
Your turn
Run a 30-trade manual backtest (about 2 hours)
Check your understanding
Check your understanding
You use the end-of-day chart to decide whether a morning trade fit your rules. Which bias is that?
You're using information you couldn't have had at the time of the trade.
Check your understanding
In DayTradingToolkit's simulation, testing 20 variations of a zero-edge rule and picking the best produced about +0.38R on the test data. What happened on fresh trades?
Choosing the best of many variations selects luck. On new data, a rule with no true edge averages zero.
Check your understanding
What's a simple defense against overfitting?
Untouched data gives an honest check on rules you've already finalized, but it only works once.
Key takeaways
- Backtesting applies exact rules to past data to see how they would have performed.
- Manual method: exact rules, fair sample, candle-by-candle replay, log every trade, analyze.
- Record results in R with costs, and track expectancy, the longest losing streak and results by day type.
- Trying many rule variations makes the best one look good by luck, so keep some data unseen.
- Treat a backtest as a filter, then move on to paper trading before real money.
Frequently asked questions
Is a 20-trade backtest enough?
How many trades do I need on a 5-minute chart?
Is manual backtesting better than automated backtesting?
Is paper trading the same as backtesting?
Why are my live results worse than my backtest?
How long should a backtest cover?
Up next: is +0.16R a real edge?
Sam's backtest showed a positive expectancy, and he was tempted to call it an edge. But 50 trades is still a small sample, and a few lucky trades could explain the whole result. Lesson 81: Trading Edge Explained shows how to judge whether a result like his is likely to be real or just luck.
Disclaimer
Article Sources
- Bailey and López de Prado, tools for detecting backtest overfitting (restating Bailey, Borwein, López de Prado and Zhu, 2014) - With five years of daily data, no more than about 45 variations of a strategy should be tried before the best result is likely to be chance.davidhbailey.com
- Sullivan, Timmermann and White (1999), Data-Snooping, Technical Trading Rule Performance, and the Bootstrap, Journal of Finance - A bootstrap method to adjust for data snooping, applied to 100 years of Dow Jones data and an expanded set of the rules studied by Brock, Lakonishok and LeBaron.ideas.repec.org
- Brock, Lakonishok and LeBaron (1992), Simple Technical Trading Rules and the Stochastic Properties of Stock Returns, Journal of Finance - A classic historical test of 26 simple moving-average and breakout rules.ideas.repec.org
- CFA Institute, Does Academic Research Destroy Stock Return Predictability? (McLean and Pontiff, 2016) - Across 97 predictors, average monthly returns fell from 0.582% in-sample to 0.402% out-of-sample and 0.264% after publication.rpc.cfainstitute.org
- TradingView Support, Bar Replay: how and why to test a strategy in the past - How replay mode steps forward one bar at a time, and the plan and data limits on intraday history.tradingview.com






