Backtesting is testing a trading strategy on historical data: you apply fixed entry, exit and sizing rules to past prices and record the trades they would have produced. The result shows whether the rules had an edge in that period, how large it was after costs, and how deep the losing stretches got, before you risk money on them.
A backtest does not predict the future. It filters out ideas that would not have worked even in hindsight. Once a backtest gives you a win rate and an average win and loss, the equity curve simulator shows the range of outcomes and drawdowns those numbers can produce.
What a backtest involves
Every backtest has the same four parts:
| Part | What it is | Example |
|---|---|---|
| Rules | Objective entry, stop, exit and position-size rules | Buy when the 50-day moving average crosses above the 200-day; sell on the cross back below |
| Data | Historical prices for the market and timeframe you trade | Daily SPY bars, 2010–2025 |
| Engine | The way the rules are applied: by hand, with bar replay, or in code | A spreadsheet, TradingView’s Strategy Tester, a Python script |
| Metrics | The numbers used to judge the result | Win rate, expectancy, profit factor, maximum drawdown |
The rules must be precise enough that two people running the test would take exactly the same trades. “Buy the dip” is an idea; “buy at the next open after the close falls 3% below the 10-day average, with a stop at the 20-day low” is a testable rule.
What a backtest tells you, and what it does not
It can tell you:
- Whether the rules made money in the test period after commissions and slippage.
- The expectancy per trade, so you can compare strategies of different sizes.
- The worst drawdown and longest losing streak, so you can size positions you could keep trading through.
- How results changed across bull, bear and sideways stretches.
It cannot tell you:
- That the edge will continue. Markets change, and an edge that is widely known tends to shrink.
- How you will execute. A backtest takes every signal; a person under pressure skips some and improvises others.
- Exact fills. Gaps, fast markets and thin liquidity fill worse than historical bars suggest.
That is why a passed backtest leads to forward testing, not straight to full size.
Types of backtest
- Manual backtest. You step through the chart bar by bar, ideally with bar replay so future bars are hidden, and log each signal in a spreadsheet. Slow, but it works for any rule you can write down and teaches you how the setup behaves.
- Automated backtest. Software runs the rules over the data: TradingView Pine Script strategies, the MetaTrader 5 Strategy Tester, NinjaTrader’s Strategy Analyzer, or Python libraries such as backtrader. Fast enough to test hundreds of trades across many symbols.
- In-sample and out-of-sample. The data is split: you build the rules on one period and test them once on another you did not look at. A strategy that only works on the data it was built on is overfitted.
- Walk-forward analysis. A rolling version of the same idea: build on one window, test on the next, move forward and repeat. It is the most demanding of the three and the closest to how a strategy is actually traded.
The step-by-step process, with a worked example of rules, costs and the resulting numbers, is in how to backtest a trading strategy.
Backtesting vs forward testing vs paper trading
| Backtesting | Forward testing / paper trading | Live trading | |
|---|---|---|---|
| Data | Historical | Live market, in real time | Live market, in real time |
| Money at risk | None | None | Real |
| Speed | Years of trades in hours | As fast as the market produces signals | Same |
| Tests | Whether the rules had an edge | Whether the edge holds now, and whether you can follow the rules | Real fills and real emotions |
The usual order is backtest, then paper trading, then a small live account. Each step checks something the previous one could not.
Three biases that make backtests look better than reality
- Overfitting (curve-fitting). Adjusting rules or parameters until they fit the past. Warning signs: many conditions, results that collapse when a parameter changes slightly, and a much weaker out-of-sample result.
- Lookahead bias. Using information that was not available at the time of the trade, for example entering at today’s open on a signal from today’s close.
- Survivorship bias. Testing only on assets that still exist. A stock strategy run on today’s index members ignores the companies that were delisted or went bankrupt along the way.
A fourth problem is simply ignoring costs. Commissions, fees and slippage matter most for short-term strategies with small targets; see the cost example in what is scalping.
How to judge a backtest
Net profit alone says little. Judge a backtest on:
- Number of trades. At least 50–100 on one fixed set of rules; with fewer, the win rate has too wide a margin of error to mean much.
- Expectancy in R or dollars per trade, after costs.
- Win rate together with average win and average loss. A high win rate with large losses can lose money.
- Maximum drawdown. Whether you could keep trading through it at your planned size. See what is maximum drawdown.
- Out-of-sample result. Weaker than in-sample is normal; near zero means the edge was probably fitted to the data.
Video: Binance Academy’s two-minute explainer of what backtesting is and what it can and cannot tell you.
After the backtest: compare it with live trades
Once you trade the strategy, on paper or live, log every trade with the strategy’s name and compare the same metrics with the backtest every 20–30 trades. If live results fall short, the gap usually comes from fills worse than assumed, trades you skipped or took outside the rules, or a change in the market. A trading journal is where that comparison happens.
Frequently asked questions
What does backtesting mean in trading?
It means running a strategy’s rules over past market data to see what trades they would have taken and what those trades would have returned. It is a test of the rules, done before risking money.
Is backtesting reliable?
It is reliable for rejecting ideas: rules that lose money in hindsight, after costs, are unlikely to work going forward. It is less reliable for predicting returns, because of overfitting, changing markets and the gap between simulated and real execution.
What is the difference between backtesting and paper trading?
Backtesting uses historical data and can cover years in hours. Paper trading applies the rules to the live market in real time with simulated money, which also tests whether you can follow them.
Can I backtest without coding?
Yes. Step through charts with bar replay and log each signal in a spreadsheet, or use the visual strategy tools built into charting platforms. The how-to guide covers the manual method.
Related reading
- How to backtest a trading strategy — the full process with a worked example
- Equity curve simulator — losing streaks to expect from a win rate and R
- Portfolio Visualizer backtest — backtesting an investment portfolio
- What is paper trading — the forward test after a backtest
- What is maximum drawdown — reading the worst stretch of a test
Start journaling with TradeReview for free — see if live results match your backtest.
