Home › Blog

Backtesting Trading Strategies: How to Do It Properly

Updated 2026-11-16 · 10 min read

Backtesting a trading strategy means applying its rules to historical market data to see how it would have performed. Done properly, it shows you how a strategy behaves: its win rate, its expectancy, its drawdowns and its losing streaks. It cannot predict future profits, but it can tell you whether a set of rules is worth testing further before you risk real money.

Backtesting trading strategies is one of the most useful habits a trader can build. It is also one of the easiest to get wrong. If a backtest is careless, you get a result that looks good on paper and then falls apart in a live account. If it is careful, you get a realistic picture of how a strategy behaves, including the uncomfortable parts.

This guide covers what backtesting is, how manual and automated testing compare, how many trades you need, which metrics to record, the biases that distort results and why forward testing should come before real money.

What is backtesting in trading?

Backtesting is the process of taking a clearly defined set of trading rules and applying them to past price data, as if you had traded them at the time. You record every trade the rules would have produced and then analyse the results.

The key phrase is clearly defined. A strategy can only be backtested if its rules are specific enough that two people would place the same trades. 'Buy when the trend looks strong' cannot be tested. 'Buy when the closing price crosses above the 50-period moving average, with a stop-loss below the most recent swing low and a target at twice the risk' can.

A backtest answers questions such as:

  • Did these rules have a positive edge over a meaningful sample of trades?
  • How large were the drawdowns along the way?
  • How long were the losing streaks?
  • Does the strategy still hold up once trading costs are included?

Why backtesting trading strategies matters

Without testing, a trader is relying on a handful of memorable trades, which is a poor basis for decisions. People tend to remember big wins and explain away losses. A structured backtest replaces impressions with a record.

Backtesting matters for three main reasons:

  • It filters out weak ideas cheaply. Finding out on historical data that a strategy has no edge costs time, not money.
  • It sets realistic expectations. You learn what normal looks like, including normal losing periods.
  • It supports risk management. Knowing the historical drawdown helps you choose a position size that you can actually live with.

Manual vs automated backtesting

There are two broad ways to backtest: manually, by scrolling through charts and logging trades by hand, or automatically, by coding the rules and letting software run them over historical data. Both are valid, and many traders use both.

AspectManual backtestingAutomated backtesting
How it worksYou move through charts bar by bar and record each trade in a spreadsheetRules are coded and run by software over historical data
SpeedSlow: a few hundred trades can take daysFast: thousands of trades in minutes
Skills neededChart reading and disciplineProgramming or a platform's strategy builder
StrengthsBuilds intuition and familiarity with how setups look in real timeConsistent, repeatable, large samples, easy to test variations
WeaknessesProne to human error and hindsight biasProne to overfitting and coding mistakes; data quality matters
Best forDiscretionary elements and learning a setup deeplyFully rule-based systems

Manual testing is a good way to learn a strategy, because you see every setup develop. Automated testing gives you larger, more consistent samples. The risk with automation is that it becomes very easy to tweak settings until the results look perfect, which leads directly to overfitting (covered below).

How to backtest a trading strategy step by step

Whatever method you use, the process is broadly the same:

  1. Write down the rules in full. Entry conditions, exit conditions, stop-loss placement, take-profit logic, position sizing, which markets and which timeframes. If a rule is ambiguous, fix it before you start.
  2. Choose your data. Use good-quality historical data covering different market conditions: trending, ranging, calm and volatile periods.
  3. Split the data. Keep a section of data aside that you do not look at while developing the strategy. This 'out-of-sample' period is used later to check whether the results hold up.
  4. Include costs. Add spreads, commissions, slippage and, where relevant, overnight financing.
  5. Record every trade. Date, direction, entry, stop, exit, result in money and in R (explained below).
  6. Analyse the metrics. Win rate, average R, expectancy, maximum drawdown and the longest losing streak.
  7. Test out of sample. Run the unchanged rules on the data you set aside. A large drop in performance is a warning sign.
  8. Forward test. Trade the strategy on a demo account or with very small size before committing real capital.

How many trades do you need? Why 100+ matters

A common rule of thumb is to collect at least 100 trades, and more is better. The reason is simple: small samples are dominated by luck.

Imagine a strategy with no real edge, where each trade is roughly a coin flip. Over 10 trades, getting 7 winners is entirely possible by chance, and it would look like a 70% win rate. Over 100 trades, random results tend to settle much closer to the true underlying rate, so a genuine edge becomes easier to separate from noise.

A larger sample also gives you a better view of the bad periods. A strategy tested over 20 trades may never have shown its worst losing streak. Over several hundred trades, you are far more likely to have seen what a rough patch really looks like.

Bear in mind that 100 trades is a minimum, not a guarantee. If those 100 trades all come from a single month of unusual market conditions, the sample is still narrow. Aim for both a decent number of trades and a variety of market environments.

Key metrics to record in a backtest

Profit alone tells you very little. Two strategies can make the same amount of money with very different risk. These are the core metrics to track.

Win rate

Win rate is the percentage of trades that were profitable. It is the most quoted metric and the most misunderstood. A high win rate is not necessarily good, and a low one is not necessarily bad. What matters is how the size of the wins compares with the size of the losses.

Average R (risk multiple)

R is the amount you risk on a trade, typically the distance from entry to stop-loss. If you risk 100 and make 200, that trade is +2R. If you hit your stop, it is −1R. Measuring results in R makes trades comparable, regardless of position size or account balance. Record the average winning trade and average losing trade in R.

Expectancy

Expectancy combines win rate and average R into one number: the average amount you would expect to make or lose per trade over many trades.

Expectancy = (win rate × average win) − (loss rate × average loss)

A hypothetical example: a strategy wins 45% of the time, with an average win of 2R and an average loss of 1R.

  • (0.45 × 2R) − (0.55 × 1R) = 0.90R − 0.55R = 0.35R per trade

If you risk 100 per trade, that would be an average of 35 per trade over a large number of trades, before costs. If costs average 0.10R per trade, expectancy falls to 0.25R. Notice that this strategy loses more often than it wins and can still have positive expectancy. A negative expectancy means the rules, as tested, lose money over time, however good the win rate looks.

Maximum drawdown

Maximum drawdown is the largest fall from a peak in account value to a subsequent low, before a new peak is reached. If a hypothetical account grows to 10,000 and then falls to 8,500 before recovering, the drawdown is 1,500, or 15%.

This metric matters because it reflects what you would have had to sit through. It is also worth remembering that live drawdowns can be larger than the backtested maximum. Historical data shows what did happen, not the worst that can happen.

Losing streaks

Record the longest run of consecutive losing trades. Even strategies with positive expectancy produce long losing streaks. Using the example above, with a 55% chance of losing each trade, the probability that any given sequence of five trades are all losers is 0.55 to the power of 5, which is roughly 5%. Across hundreds of trades, streaks of five, six or more are to be expected rather than a surprise.

MetricWhat it tells youWhy it matters
Win rateHow often trades are profitableOnly meaningful alongside win and loss size
Average RTypical size of wins and losses relative to riskMakes trades comparable across position sizes
ExpectancyAverage result per trade over timeShows whether the strategy has an edge at all
Maximum drawdownLargest peak-to-trough fallGuides position sizing and emotional readiness
Longest losing streakMost consecutive lossesPrepares you for normal bad runs

Common backtesting biases and how to avoid them

Most misleading backtests are not dishonest. They are distorted by biases that are easy to fall into. These are the most common ones.

Overfitting (curve fitting)

Overfitting happens when you adjust a strategy's parameters so precisely to past data that it captures random noise rather than a genuine pattern. The classic sign is a strategy with many rules and finely tuned settings, such as a 37-period average combined with an RSI level of 63, that produces a near-perfect equity curve.

To reduce overfitting:

  • Keep rules simple and few in number.
  • Check that nearby parameter values give broadly similar results. If changing 37 to 35 ruins the strategy, the edge is probably not real.
  • Always validate on out-of-sample data you did not use to build the strategy.

Look-ahead bias

Look-ahead bias means using information that would not have been available at the moment of the trade. Examples include entering at the open based on that day's closing price, or using a daily high or low before the day has finished. In manual testing, simply seeing the next candles on the chart can influence decisions. Hide future price action and make sure every rule uses only data available at the time.

Survivorship bias

Survivorship bias occurs when your data includes only instruments that still exist today. In share trading, for example, companies that were delisted or went bust may be missing from the data set, which makes historical results look better than they would have been. Use data sets that include delisted instruments where this is relevant.

Ignoring trading costs

Spreads, commissions, slippage and financing charges can turn a profitable-looking strategy into a losing one, especially for short-term strategies that trade frequently with small targets. Include realistic costs, and err on the side of caution. Slippage is often worse during news events and fast markets.

Other pitfalls worth knowing

  • Selection bias: testing many strategies and only reporting the one that worked.
  • Regime dependence: a strategy that only works in one type of market, such as a strong trend.
  • Data quality issues: gaps, errors or unrealistic fills in historical data.

Forward testing and demo trading before real money

A backtest is the first filter, not the final one. The next step is forward testing, also called paper trading or demo trading: running the strategy in real time, on live prices, without risking real capital or with very small size.

Forward testing reveals things a backtest cannot:

  • Whether you can actually execute the rules when prices are moving in real time.
  • How real spreads and fills compare with your assumptions.
  • Whether the strategy's behaviour in current conditions resembles the historical results.

A reasonable approach is to forward test until you have a meaningful number of trades, then compare the metrics with your backtest. If expectancy, win rate and drawdown are broadly in line, you have more reason to proceed. If they diverge sharply, find out why before going further. Even then, starting live trading with reduced position size is a prudent step, because demo accounts do not fully replicate live execution or the emotional pressure of real money.

How a backtest builds the confidence to execute without hesitation

One of the most underrated benefits of backtesting is psychological. Many traders abandon a sound strategy during an ordinary losing streak, simply because they do not know whether it is normal.

If your backtest showed that the strategy had losing streaks of seven trades and drawdowns of 12%, then a run of five losses is uncomfortable but expected. You can keep following the rules instead of changing them in the middle of a bad patch, which often means missing the trades that eventually recover the losses.

This confidence should be grounded, not blind. A backtest tells you what normal looked like in the past. It also helps you define in advance what abnormal looks like, for example a drawdown well beyond the historical maximum, at which point you stop and reassess. Having both thresholds written down before you start reduces impulsive decisions in either direction.

Honest reporting: separating backtests from live results

Whenever you look at performance figures, from your own records or from any service, check whether they come from historical simulation or from real trading. The two are not equivalent. Backtested results benefit from hindsight and idealised execution, while live results include real fills, real costs and real decisions.

Good practice is to label them clearly and never blend them into a single figure. As one example, Cortex Automation separates the months tested on historical data from the months traded on real accounts in its track record, so readers can see which is which. Whatever the source, it is reasonable to ask that question before drawing conclusions.

Risks and limitations of backtesting

Even a careful backtest has limits that every trader should keep in mind:

  • The past does not repeat exactly. Market structure, volatility and behaviour change over time.
  • Execution is idealised. Real orders can suffer slippage, partial fills or gaps, particularly around news.
  • Drawdowns can be deeper live. The historical worst case is not a ceiling.
  • Leverage magnifies losses. With leveraged products, losses can exceed what a backtest suggested if position sizing is too aggressive.
  • A positive backtest is not proof of an edge. It is evidence that the idea deserves further testing.

Used with these limits in mind, backtesting is a practical tool for filtering ideas, setting realistic expectations and sizing risk sensibly. Used carelessly, it produces false confidence.

This article is general information and education only, not financial advice. Trading involves risk, and you may lose some or all of the money you invest. Past performance, whether backtested or live, does not guarantee future results. Consider your circumstances and seek independent advice if needed.

Frequently asked questions

What is backtesting in trading?

Backtesting is applying a clearly defined set of trading rules to historical price data to see how the strategy would have performed. It means recording each trade it would have taken and analysing metrics such as win rate, expectancy and drawdown.

How many trades do I need for a reliable backtest?

A common rule of thumb is at least 100 trades, and more is better. Small samples are heavily influenced by luck. The trades should also cover different market conditions, not just one period.

Is manual or automated backtesting better?

Neither is better in every case. Manual backtesting builds familiarity with a setup but is slow and prone to human error. Automated backtesting is fast and consistent but makes overfitting easy. Many traders use both.

What is expectancy in trading?

Expectancy is the average result per trade over many trades: (win rate × average win) minus (loss rate × average loss). For example, a 45% win rate with 2R average wins and 1R average losses gives 0.35R per trade before costs.

Does a good backtest guarantee profits?

No. A backtest only shows how rules performed on past data. Markets change, live execution differs and drawdowns can be deeper than in testing. Forward testing and cautious position sizing are still essential.

What is the difference between backtesting and forward testing?

Backtesting uses historical data. Forward testing runs the strategy in real time on live prices, usually on a demo account or with small size, to check whether the results hold up in current conditions.

Want to see how an automated system works, with the money in your own account? See results and simulator →

Related articles