All lessons

Lesson 2 of 10 · Published Aug 26, 2026 · 5 min read

How to Backtest a Trading Strategy

Share

A backtest replays your strategy's rules against historical market data and records every trade it would have taken. It is the closest thing trading has to a laboratory: before risking a dollar, you can see how an idea would have survived years of real market conditions, including the crashes, the chop, and the boring stretches in between.

A backtest cannot prove a strategy will make money. It can do something almost as valuable: quickly prove that most ideas would not have, so you only take the survivors seriously.

What a backtest tells you

Running the rules over history produces a trade list and an equity curve, the running total of your account value. From those, a handful of metrics carry most of the signal:

  • Total and annualized return. What the strategy made over the period, normalized so different test lengths compare fairly.
  • Maximum drawdown. The deepest peak-to-trough fall in the equity curve. This is the number that predicts whether you would actually stick with the strategy, because you will live through that drawdown again.
  • Sharpe ratio. Return per unit of volatility. As a rough compass, below 1.0 is weak, above 1.0 is respectable, and numbers far above 2.0 in a retail backtest deserve suspicion, not celebration.
  • Win rate and profit factor. How often trades win, and gross profits divided by gross losses. Neither means much alone: trend strategies thrive on 35% win rates, and a 90% win rate with rare huge losses can be ruin in disguise.
  • Trade count. Fewer than about 30 trades and the statistics are mostly noise, whatever the other numbers say.

Read them together. A strategy with modest returns, a shallow drawdown, and 200 trades across five years is a far stronger result than a spectacular return built on 12 lucky trades.

The traps that make backtests lie

Most impressive backtests are broken in one of a few standard ways. Knowing them is half the craft.

Overfitting is the big one. If you tune parameters until history looks perfect, you are no longer testing a strategy; you are memorizing the past. The tell is fragility: if RSI 14 makes money but RSI 12 and 16 lose, you found noise, not signal. Robust edges degrade gracefully as parameters shift.

Look-ahead bias means the simulation accidentally uses information that was not available at decision time, like acting on a daily close before the day has closed. A proper backtesting engine prevents this by construction, but it is the first thing to suspect when results look too clean.

Survivorship bias creeps in when the test universe only contains instruments that still exist today. Testing "the current S&P 500" over ten years quietly excludes every company that fell out along the way.

Ignoring costs flatters high-frequency ideas most. Fees, spread, and slippage are small per trade and decisive in aggregate. A strategy that trades 40 times a day must clear its cost hurdle before it earns anything.

A sound backtesting workflow

  1. Write the rules first. Entry, exit, sizing, universe, timeframe, all fixed before you look at results, so the data cannot seduce you into redefining the idea mid-test.
  2. Test on a long, varied window. Include at least one period that should hurt the strategy: a crash for trend followers, a strong trend for mean reverters.
  3. Include realistic costs for your instrument and trade frequency.
  4. Check robustness. Nudge each parameter and confirm the result bends rather than shatters.
  5. Hold out recent data. Develop on the older window, then run once on the held-out period. One clean out-of-sample pass beats fifty optimized in-sample ones.
  6. Only then consider capital, sized by the risk rules covered in Risk Management for Algorithmic Trading.

Backtesting without building the lab

Writing a correct backtesting engine is genuinely hard; the biases above are exactly the bugs beginners write. On Horizon, you describe a strategy in plain English and the platform builds it and runs the backtest against years of historical data, with the equity curve, drawdown profile, and trade-level metrics laid out for inspection. The strategy templates directory is a good place to calibrate your eye: each template ships with its historical backtest, so you can see what honest results look like across different strategy styles.

However you run it, treat the backtest as a filter, not a promise. It exists to kill weak ideas cheaply. The ideas that survive graduate to the next questions: how much to risk, covered next in Risk Management for Algorithmic Trading, and how to go live safely, covered in How to Automate a Trading Strategy.

Frequently asked questions

How much historical data do I need for a backtest?

Enough to cover several distinct market conditions: a strong trend, a crash, and a sideways stretch at minimum, which usually means years rather than months. As a separate check, aim for at least 30 trades in the results; below that the statistics are mostly noise.

What is a good Sharpe ratio in a backtest?

For a retail strategy, above 1.0 is respectable and above 2.0 is strong. Far higher numbers in a backtest usually signal a problem, most often overfitting or missing costs, rather than a miracle strategy.

Can a strategy that backtests well still lose money live?

Yes, and the usual causes are known: the backtest was overfit to history, costs and slippage were modeled too kindly, or the market regime changed. This is why a good backtest earns a strategy paper trading, not immediate capital.

Can I backtest without writing code?

Yes. On Horizon you describe the rules in plain English and the platform builds and backtests the strategy against years of data. What no tool can automate is stating the rules precisely; ambiguity in, noise out.

Related reading

Horizon

Type a sentence trade the market

Stay in touch

© 2026 Horizon Trade. All rights reserved.

Trading and investing involve significant risk. Many participants lose money through trading and investment activities. Nothing on this site or within the Horizon platform should ever be interpreted as financial advice. Any decision to buy, sell, hold or trade securities, cryptoassets, commodities or any other financial instruments carries risk and should be made with the guidance of licensed financial professionals. Past results never guarantee future performance.

Climb the list.
Invite others.

Horizon provides technology and data for informational purposes only and is not a registered broker-dealer, investment adviser, or fiduciary. You are solely responsible for all trades executed through your connected broker. Learn more.

How to Backtest a Trading Strategy | Horizon Academy | Horizon Trade