Backtesting is the process of running a set of written trading rules against historical market data to see how they would have behaved. Done properly it tells you the shape of a strategy: how often it wins, how much it gives back, how long it can stay underwater, and whether you could realistically live through that. Done carelessly it produces a flattering equity curve that means nothing. The difference is almost entirely in method, and the four steps below are the method. For the wider context on what backtesting is and where it fits, start with our backtesting guide; this article is the practical procedure.

What Backtesting Tells You, and What It Does Not

A backtest tells you how a specific set of rules behaved in conditions that have already happened. That is genuinely valuable, because it establishes what is normal for your system: the depth of drawdown you should expect, the length of losing streaks, and the proportion of the return that came from a handful of trades.

What a backtest cannot tell you is what happens next. It cannot know about market conditions absent from your sample, and it is easily corrupted by the person running it. Every decision you make after seeing results, and every rule you add because it improves the curve, moves the test further from a genuine prediction and closer to a description of the past. Holding that distinction firmly is what separates a useful backtest from an expensive one.

Step 1: Define Objective Rules

Write your rules so precisely that two people applying them to the same data would take exactly the same trades. Anything requiring interpretation is not a rule, and a strategy containing interpretation cannot be tested, only illustrated.

Your rule set needs entry conditions, exit conditions covering both profitable and losing exits, position sizing that determines how much capital each trade receives, and portfolio-level constraints such as maximum simultaneous positions. It also needs a defined universe: which stocks, which exchange, which liquidity filter. Vagueness here is the most common reason a live system behaves nothing like its test.

Step 2: Choose Your Data and Software

Your backtest inherits every flaw in your data, so this decision matters more than beginners expect.

Price data must be adjusted for splits and other capital events, or your rules will read a corporate action as a price move. Dividend adjustment is a separate decision rather than a requirement, and most platforms leave it switched off by default. Adjusting for dividends gives you a total-return series, which suits momentum and rotation work. Leaving them out keeps the series closer to the prices you would actually have traded. Either is defensible provided you know which one you have chosen, and provided you do not apply price-level filters such as a minimum share price to an adjusted series, because a filter like that will pass stocks in the backtest that never traded at those levels in real time.

The larger data problem is survivorship bias, and it comes in two forms that are not equally dangerous. Index constituency bias is the serious one: testing a strategy against the companies that are in an index today means testing against a list selected by the very performance you are trying to predict. Delisting bias, meaning a universe that omits companies which went bankrupt or were acquired, is the one most articles lead with, and it matters less than its reputation suggests for long-side systems with real exit rules, because a company sliding toward failure usually triggers an exit well before it disappears. Use historically accurate index constituents. That single choice removes more illusory performance than anything else in this step.

For software, the tools I use and teach for end-of-day stock systems are RealTest and AmiBroker, both of which handle portfolio-level testing across a universe of stocks rather than testing one symbol at a time. That capability is not optional. A system tested on a single stock tells you almost nothing about how it behaves when it is choosing among hundreds and competing for capital.

Step 3: Run the Test and Read the Metrics

Run the rules across roughly thirty years of market history if your data allows it, over a universe of thousands of stocks, so the test generates thousands of trades across several full market cycles and more than one serious bear market. A system that has only met one downturn has not been tested, it has been introduced. Then read the results in the right order, because the sequence people naturally use is backwards.

Metric What it tells you What to watch for
Maximum drawdown The deepest peak-to-trough fall in account value Read this first. If you cannot live through it, nothing else matters
Time in drawdown How long the system stayed below a previous high Long underwater periods break more traders than deep ones
CAGR Compound annual growth rate over the test Meaningless without the drawdown beside it
Profit factor Gross profit divided by gross loss Very high values on few trades usually indicate a fluke or a fitted rule
Expectancy Average result per trade Combine with trade frequency to understand real-world pace
Number of trades Sample size Small samples prove nothing, however good they look
Contribution of top trades How much of the profit came from a few positions If removing the best five trades destroys the result, the edge is fragile

Read drawdown before return, every time. Return determines whether a system is worth trading; drawdown determines whether you will still be trading it when the return arrives.

Step 4: Stress-Test Before You Trust It

A single good backtest is a hypothesis, not a result. Four checks separate a system that is genuinely robust from one that has been fitted to history.

  • Out-of-sample testing. Develop on one period, then test on a period you never looked at during development. A system that only works on its development data has memorised rather than learned.
  • Parameter sensitivity. Vary each parameter through a range. Results should degrade gradually. If a small change collapses performance, you have found a peak in the historical noise rather than an edge.
  • Realistic costs. Include brokerage and slippage. Strategies with many small winners are frequently profitable in theory and unprofitable once real costs are applied.
  • Market-condition breakdown. Look at performance separately through bull markets, bear markets and flat periods, so you know in advance which environment will hurt. Mean reversion and trend following struggle in opposite conditions, so knowing which one you are running tells you which market will be the hard one.

Common Backtesting Mistakes That Invalidate Results

Most broken backtests fail for one of five reasons. Curve fitting, meaning adding rules and tuning parameters until the past looks perfect, is the most common and the most seductive. Look-ahead bias means using information that was not available at the moment of the trade, such as acting on a closing price at the open of that same day. Survivorship bias comes from incomplete data as described above. Over-optimisation on too few trades dresses up randomness as an edge. And ignoring costs turns marginal systems into profitable ones on paper only.

There is a sixth that is harder to catch because it happens across sessions rather than within one: testing dozens of variations and keeping the best. Even random rules produce a winner if you generate enough of them, so track how many variations you have tried, and treat your hundredth attempt with far more suspicion than your first.

If you would like the structured version of this process with the software walkthroughs included, our free RealTest Launchpad course covers it end to end.

Frequently Asked Questions

How much data do you need to backtest a trading strategy?

Enough to cover multiple market cycles including at least one serious bear market, which in practice means testing across decades rather than years wherever your data allows. Sample size matters as much as span: a strategy that trades rarely needs a longer history to produce enough trades to mean anything, and a few hundred trades across varied conditions is worth far more than a few dozen from a single bull run.

What is a good backtest result?

There is no universal threshold, and any specific number offered as one should be treated with suspicion. Judge results as a set: a drawdown you could genuinely tolerate, a return that justifies the effort, enough trades to be meaningful, and stability when you vary the parameters. Robustness matters more than any headline figure.

Can backtesting predict future performance?

No. Backtesting describes how rules behaved in conditions that already occurred, which is the best available evidence and still not a forecast. Its real value is establishing what is normal for your system so that a drawdown feels like information rather than an emergency.

What is the best backtesting software for stocks?

For end-of-day stock and ETF systems, RealTest and AmiBroker are the two we teach, mainly because both test at portfolio level across a universe of stocks. The right choice depends on your coding comfort and what you trade, and the data feeding the software matters more than the software itself.


author avatar
Adrian Reid Founder and CEO
Adrian is a full-time private trader based in Australia and also the Founder and Trading Coach at Enlightened Stock Trading, which focuses on educating and supporting traders on their journey to profitable systems trading. Following his successful adoption of systematic trading which generated him hundreds of thousands of dollars a year using just 30 minutes a day to manage his system trading workflow, Adrian made the easy decision to leave his professional work in the corporate world in 2012. Adrian trades long/short across US, Australian and international stock markets and the cryptocurrency markets. His trading systems are now fully automated and have consistently outperformed international share markets with dramatically reduced risk over the past 20+ years. Adrian focuses on building portfolios of profitable, stable and robust long term trading systems to beat market returns with high risk adjusted returns. Adrian teaches traders from all over the world how to get profitable, confident and consistent by trading systematically and backtesting their own trading systems. He helps profitable traders grow and smooth returns by implementing a portfolio of trading systems to make money from different markets and market conditions.