What is backtesting?
Backtesting is checking a trading strategy on the past. You take a set of rules, apply them to sessions that already happened, write down every trade the rules would have taken, and look at the results. If the rules lost money on the past, there is little reason to expect them to make money on the future.
There are two ways to do it:
- A coded backtest. The rules are written as a program that runs over years of data in seconds. It needs rules precise enough for a computer, and data detailed enough for the setup.
- A manual backtest. You go through past sessions yourself, one bar at a time, and decide each trade as if it were happening. It is slow, but it fits the setups small-cap day traders use, which often depend on news, on how a stock behaves at its levels, and on what the rest of the market is doing.
This guide is about the second kind. Done well, a manual backtest gives you two things at once: an honest record of how a setup has behaved, and practice reading it.
Write the rules before you look at a chart
A backtest tests rules, so they have to exist before the first session. Rules written after you have seen the charts tend to describe the trades that worked.
Write them in a few lines, precise enough that someone else could follow them:
- The candidate. What makes a stock worth watching: a gap of a certain size, a minimum volume or relative volume, a price range, a float limit.
- The entry. The exact event that gets you in, such as a break of the premarket high after 09:30 ET.
- The stop. Where you are wrong, as a price, before you enter.
- The exit. Where you take the trade off: a target, a level lost, or a time.
- The window. The hours the setup is allowed, such as the first hour of the regular session.
The gap and go guide is a good example of a setup that can be written this way. Whatever the setup, a rule you can't apply without thinking about it is a rule to rewrite before you start.
Pick sessions without hindsight
The most common way a backtest lies is in the stocks it looks at. Choosing the stocks you remember running means choosing the winners: every setup looks good on the days it worked.
To avoid it, pick the candidates the way you would have picked them live:
- Use the scan as it stood. Take every stock that met your candidate rules at the time, not the ones that ended up on the day's top list.
- Include the dull days. A setup that only works on the market's best days needs to be tested on the others too, because you won't know in the morning which kind of day it is.
- Decide the sessions in advance. For example, every session of the last few weeks, in order, rather than the ones that look interesting.
Replay bar by bar, and decide before the next one
On a finished chart, the right trade is obvious. The point of a manual backtest is to make each decision with only what you could have seen at that moment.
- Hide what comes next. Step the session forward bar by bar, or play it and pause. Decide at the close of a bar, never by looking ahead.
- Write the decision down before you move on. Entry, stop and exit, or "no trade" and why. A decision that isn't written is easy to change once you've seen the next bar.
- Be honest about fills. Small caps have wide spreads and fast moves. Assume you get in a little worse than the price that triggered you, and out a little worse than your stop. A stop doesn't protect you during a halt; the guide to trading halts explains why.
What to log for every trade
The log is the backtest. Keep the same fields for every trade, in a spreadsheet:
| Field | Example |
|---|---|
| Date and stock | Session of the 14th, stock A |
| Why it was a candidate | Gap of 22%, high relative volume |
| Entry, stop, exit | 4.10, 3.85, 4.60 |
| Result in R | +2R |
| Rule followed? | Yes |
| Notes | Halted once before the entry |
R is the result measured in units of risk: the distance from entry to stop. A trade that risked 25 cents a share and made 50 cents is +2R; one that hit its stop is −1R. Measuring in R lets you compare trades on stocks at different prices, and makes position size a separate decision.
Reading the results
Once you have a few dozen trades, add them up.
- The total, in R. With made-up numbers: 30 trades, of which 12 won 2R on average and 18 lost 1R. That is 24R won, 18R lost, 6R in total, or 0.2R per trade. A result near zero is a setup that, so far, doesn't pay for its risk.
- The losing streak. The longest run of losses tells you how much a bad week would have cost, and whether you could have kept following the rules through it.
- The split. Sort the log by time of day, gap size, float or day of the week. A setup that only works in the first 15 minutes is a different setup from the one you wrote.
Then look for the usual traps:
- Too few trades. A handful of trades says very little; a lucky week can look like a strategy.
- Rules that changed along the way. Each change starts a new sample. Mixing them is fitting the rules to the past.
- Costs left out. Commissions, fees and the worse fills of fast stocks can turn a small edge into nothing.
No backtest promises anything about the future. It tells you whether a setup is worth practicing further, and what to watch for when you do.
Backtesting with Traderly's replay
Traderly's replay puts the whole desk back on a past session: the scanner ranks stocks the way it ranked them that day, and the charts build second by second. That makes it a fit for the parts of a manual backtest that are hardest to do on a finished chart:
- Candidates without hindsight. The scanner in replay shows the list as it stood, so you can take every stock that met your rules, not only the ones you know ran.
- Decisions without the ending. You can pause, step forward and decide at each bar, with 1-second candles for the fast parts.
- A sample built over time. Replay covers recent sessions, so a backtest grows week by week: replay the new sessions each week and add them to the log.
In live sessions, Traderly's market data is delayed 15 minutes. In replay, the session is already over, so the delay doesn't change what you see.
From backtest to practice
A backtest says what the rules did. Following them at speed, without second-guessing, is a separate skill, and it is the one practice builds. The guide to practicing day trading lays out a routine for that, from one written setup to new sessions with rewritten rules, without money at risk.