What Is Backtesting in Trading?

By Stephanie Wong — Portfolio Manager, High Yield Credit · Published August 15, 2026 · 7 min read

Backtesting is testing a trading strategy's rules on historical prices to see how they would have performed in the past. A computer replays years of market data, applies the rules day by day as if it were trading, and reports the simulated returns, losses and trades. It is a useful way to study a strategy's behaviour across many market conditions, but it shows what would have happened, not what will happen, and nobody actually earned the results.

This guide explains how a backtest is built, which numbers to look at, and the main reasons backtests mislead.

How a backtest works

Every backtest, from a spreadsheet to professional software, follows the same basic steps.

  1. Gather historical data. Daily or hourly prices for everything the strategy might trade, ideally adjusted for splits and dividends.
  2. Write the rules precisely. "Buy when the price is above its 200-day average; sell when it falls below" is a rule a computer can follow. "Buy when it looks strong" is not.
  3. Step through time. The software moves forward one bar at a time (a day, an hour), checks the rules using only information available up to that point, and records any trades.
  4. Apply costs. A fee or slippage estimate is taken off each simulated trade.
  5. Track the account. The simulated balance rises and falls with each position.
  6. Report results. Yearly return, worst fall, time to recover, number of trades and comparison with a benchmark.

Step 3 hides the most important rule in backtesting: the strategy must never use information from the future. If a rule on 3 March uses the closing price of 4 March, the backtest is broken, usually in a way that flatters it. This mistake is called look-ahead bias, and it is surprisingly easy to make.

A tiny backtest you could do by hand

To see the idea without software, picture a deliberately simple rule tested on five weeks of made-up prices for a fund. The rule: at the end of each week, hold the fund if its price is above last week's price, otherwise hold cash for the next week. These numbers are invented purely to show the mechanics.

  • Week 1 close: $100. No previous week to compare, so start in cash.
  • Week 2 close: $104. Above $100, so the rule buys at the next opportunity and holds for week 3.
  • Week 3 close: $101. The fund fell from $104 to $101 while held, a loss of about 2.9%. Below the previous week, so the rule moves to cash.
  • Week 4 close: $97. In cash, so the fall does not affect the account.
  • Week 5 close: $99. Above $97, so the rule buys again.

Over those five weeks the fund itself went from $100 to $99, a 1% loss. The rule lost about 2.9% on its one completed trade, before costs. So in this tiny example the rule did worse than simply holding, even though it avoided the week-4 drop. That is a useful lesson in itself: sidestepping one fall does not guarantee a better result, because the rule also paid for buying after a rise and selling after a dip.

Real backtests do exactly this, only over thousands of days, with precise fill prices and costs, and with the computer doing the bookkeeping.

The numbers a backtest reports

Measure What it tells you What to watch out for
Yearly return (CAGR) Average growth per year, compounded Can hide long losing stretches
Total growth What a starting amount became Large numbers over long periods exaggerate differences
Worst fall (max drawdown) Largest drop from a peak to a low The number most likely to make you quit
Recovery time How long it took to get back to the old peak Can be years, even for strong strategies
Number of trades How active the strategy is More trades means more cost sensitivity
Benchmark comparison Return and fall of a simple alternative Without it, the other numbers mean little

Two of these deserve their own articles: max drawdown explained and CAGR vs total return.

A worked example: reading a backtest honestly

Here is a real example from AlgolaneBots's own published figures, chosen because it shows both why backtests are interesting and why they need caution.

The Leveraged Growth rotates between leveraged growth funds such as TQQQ and SOXL, volatility funds, inverse funds such as SQQQ, and bonds, based on market signals read after each close. Before the numbers, the comparison and the caveat:

  • Benchmarks over the same period, January 2011 to November 2026: the S&P 500 (SPY) returned +13.9% a year with a worst fall of 34%; the Nasdaq 100 (QQQ) returned +18.2% a year with a worst fall of 35%.
  • The strategy in its historical backtest: +129.1% a year with a worst fall of 53%. That fall came during the Covid crash, from February to March 2020, and recovered about 3 months after the bottom. The S&P 500 fell 34% in the same crash.
  • The caveat: its rules may be fitted to the years after 2010, and leveraged funds can lose value quickly.

The yearly return is extraordinary, and that is exactly why the caveat matters. When the same idea was run on a simulated three-fund version through the dot-com crash of 2000 to 2002, the result fell 91% against 47% for the S&P 500, and took 115 months to get back to its pre-crash value, against 78 months for the index. A rule set that looks brilliant on one stretch of history can look disastrous on another.

None of these figures were earned by anyone. They are a computer test on past prices, and future results will differ, possibly by a lot.

Why leveraged funds make backtests extra tricky

Funds like TQQQ aim to deliver three times the daily move of the Nasdaq 100. They reset every day, so over longer periods their return is not simply three times the index. In choppy markets, the daily reset causes a drag often called volatility decay: a fund can lose value even if the index ends up roughly where it started. Volatility funds such as UVXY are even harder to hold; UVXY has lost most of its value over long periods. A backtest that times these funds well can show huge numbers, and small changes to the timing can wipe them out. We explain this in leveraged ETF decay.

What backtesting is good for

Despite its limits, backtesting does several things nothing else can:

  • It covers many market conditions quickly. Twenty years of history, including several crashes, can be replayed in seconds.
  • It reveals the shape of losses. You can see how deep and how long the worst periods were, which a few months of live trading may never show.
  • It rules out bad ideas cheaply. If a strategy loses money even on the history it was designed around, it is unlikely to do better in the future.
  • It allows fair comparison. Two strategies tested on the same data, with the same costs, against the same benchmark, can be compared directly.
  • It shows sensitivity. Rerunning with higher costs, different start dates or slightly different rules shows how fragile a result is.

Why backtests mislead

Overfitting

If you try enough rule variations, some will fit past data beautifully by chance. Those rules have learned the noise of one period rather than anything lasting. This is the biggest single reason great backtests fail live; see overfitting: why great backtests fail live.

Hindsight in what was tested

Choosing which stocks to include after seeing which ones did well flatters the test. AlgolaneBots discloses this directly for two of its strategies; for example, Steady Growth's seven names "were picked because they already did well." Our article on hindsight and survivorship bias explains the mechanism.

Missing or unrealistic costs

A backtest that ignores spreads and slippage can overstate returns badly, especially for active strategies. Gold Breakout's backtest, for instance, shows that doubling trading costs cuts its yearly result roughly in half.

Data problems

Unadjusted splits, missing days, and prices from funds that did not exist yet (filled in by simulation) all introduce error. Simulated history should be labelled as such.

Behaviour the past never tested

Markets change. A rule that relies on a relationship that held for fifteen years can stop working when conditions shift.

Backtesting, paper trading and live trading

A backtest looks backwards. Paper trading looks forward on real prices without money at risk. Live trading uses real money. Each answers a different question, and none replaces the others.

  • Backtest: how did these rules behave across past markets?
  • Paper trade: do the rules behave the same way on prices they have never seen?
  • Live trade: what happens with real fills, real costs and real emotions?

The most reliable picture comes from all three together. We compare the first two directly in backtest vs forward test, and explain the second in what is paper trading.

Key takeaways

  • Backtesting applies a strategy's rules to historical prices to simulate past performance.
  • Always read a backtest's return together with its benchmark, worst fall and recovery time.
  • Overfitting, hindsight in stock selection and missing costs are the main reasons backtests mislead.
  • Leveraged and volatility funds can produce extreme backtest results that are fragile to small changes.
  • A backtest shows what would have happened; nobody earned it, and future results will differ.

See the rules run forward

Backtests are a starting point. To see how AlgolaneBots's five strategies behave on prices they have never seen, start a free 90-day paper trial with $10,000 of pretend money and no card. Each strategy's backtest and caveat is listed on the strategies overview, and our risk page explains the risks of trading.

Where the numbers come from: every strategy figure is from AlgolaneBots's own historical backtests, run on past prices with the method on how we test. Nobody earned them, and future results will differ. General market facts are checked against regulator and company sources. This guide is general information, not personal advice. Read the risk disclosure and how we write our guides.

Keep reading

Backtesting · 7 min read · David Gallagher

Backtest vs Forward Test: Why You Need Both

Backtest vs forward test: a backtest replays past prices, a forward test runs fixed rules on new prices. What each proves and how to use both together.

Backtesting · 7 min read · Mark Sullivan

CAGR vs Total Return: Reading Strategy Results

CAGR vs total return: total return shows the overall gain, CAGR shows the smoothed yearly rate. Learn when each misleads and how to compare strategy results.

Backtesting · 7 min read · Douglas Kim

Max Drawdown Explained With Real Examples

Max drawdown is the largest peak-to-bottom fall in an account's value. See how to calculate it, why it matters more than returns, and real backtest examples.