What is backtesting
Backtesting replays fixed trading rules over past price data. Learn what a test can and cannot tell you, which numbers to read first, and the common traps.
Part of the Backtesting and Research track on Agenticks. About 9 minutes, written for a advanced reader.
Last reviewed .
Risk notice. Backtested and hypothetical results are simulated: no trades were placed, the rules were applied to past data with the benefit of hindsight, and they may not reflect liquidity, slippage or every cost. Past results, real or simulated, do not predict future results.
Key takeaways
- A backtest replays fixed, written rules over past data and reports what would have happened. It describes the past, not the future.
- A rule is only testable when a stranger or a computer could follow it the same way every time.
- Read the trade count, the expectancy and the worst drawdown together before trusting any result.
- Bad data, too few trades, peeking at the future and ignored costs can all make a test look far better than the idea is.
A backtest is a test that takes a fixed set of trading rules and runs them over past price data to see how they would have behaved. That is the whole idea, and it is more honest than it sounds. You are not predicting anything. You are asking a narrow question: if I had followed these exact rules across this stretch of history, what would have happened? The reason this matters is that most trading opinions are untestable. "This setup works" is a feeling. A backtest forces the feeling into something measurable, then lets the numbers, not your memory, decide whether the idea has any structure.
Backtesting is three honest parts
Past data, plus strict rules, plus honest evaluation. Drop any one of the three and the test stops meaning anything. Real history keeps it grounded. Strict rules keep you from quietly changing your mind. Honest evaluation keeps a lucky run from being mistaken for an edge.
The strict rules part is where most people cheat without noticing. A rule has to be written down precisely enough that a computer, or a stranger, could follow it the same way every time. "Buy when it looks strong" is not a rule. "Enter long when price closes above the prior day's high, exit at a fixed stop or the close of the session" is a rule. If you cannot write the entry and exit as something mechanical, there is nothing to test yet. You are still describing a vibe. Turning the vibe into a rule set is the real work, and it usually exposes how vague the original idea was. The steps are in turning an idea into a testable rule set.
The historical data part sounds boring and is quietly the most dangerous. A test is only as trustworthy as the data behind it. Gaps, bad ticks, the wrong timeframe, or a sample that only covers one calm market can all produce a clean-looking result that means nothing. And a backtest only ever describes the past. It is not a forecast. The market regime can change, your fills will differ, and costs you ignored in the simulation are real when money is live. A test can also lie by accident, by using information that was not available yet (look-ahead bias) or by only testing on markets that survived. A backtest tells you whether an idea ever had structure. It does not promise that structure repeats.
Honest evaluation is the hardest part
A single rising equity line is easy to fall in love with. Honest evaluation means asking the uncomfortable questions instead: How many trades is this based on? What was the worst losing stretch? Would the average win still cover the average loss if I had been a little less lucky? The math, not the screenshot, has the final say.
Two numbers do most of the early work. Sample size is how many trades the result rests on. With ten trades, luck dominates and the numbers mean almost nothing. With a few hundred across different conditions, you can start to believe them, though never with certainty (why ten trades mean nothing). Expectancy is the average amount you would expect to win or lose per trade over many trades, given how often you win and how big your wins and losses are. A positive expectancy across a large sample means the rules lean in your favor mathematically. A negative one means they do not, no matter how good a few cherry-picked trades looked.
There is one more number you cannot skip: the worst peak-to-trough drop in the account, the drawdown. Even a profitable set of rules can put you through a losing stretch deep enough that most people would quit before it recovered. A result that looks great on paper but only survives if you can stomach a brutal dip is not really usable. The size of the worst stretch is part of whether an idea is tradeable at all.
Worked example: reading one small test
A rule is run over two years of history and produces 50 trades. Here is how the first three numbers come out.
| Trades | 50 |
|---|---|
| Winners (22 / 50) | 22, or 44% |
| Average win | $150 |
| Losers | 28, with an average loss of $90 |
| Net result (22 x 150 - 28 x 90 = 3,300 - 2,520) | +$780 |
| Expectancy per trade (780 / 50) | +$15.60 |
| Verdict | Positive, but 50 trades is a small sample |
Illustrative numbers, not a real test. Costs are not included here.
rules data honest
- Backtest
- Replaying fixed rules over past price data
- Expectancy
- Average win or loss expected per trade
- Sample size
- How many trades the result rests on
- Drawdown
- The worst peak-to-trough drop in the account
Put the backtesting steps in the order you should actually do them.
- Write the idea as strict, mechanical rules
- Run the rules over real historical data
- Read sample size, expectancy, and drawdown
- Decide honestly whether the idea is worth more work
Which statement is the most honest description of what a backtest tells you? Whether a set of rules had structure over the past data you tested Exactly. A backtest describes the past. It can show structure, but it cannot promise the structure repeats.
This run scanned 1,548 days and produced no trades at all, and the screen says so before anything else. A result with no sample behind it tells you nothing, however the grade or the bars look.
You understand what a backtest really is
Past data, strict rules, and honest evaluation. You can now tell the difference between a real test and a good-looking screenshot.
Check your understanding
- In the worked example, 50 trades netted +$780. What was the expectancy per trade?
- +$15.60. Expectancy is the net result divided by the number of trades: 780 / 50 = 15.60.
- Which detail most weakens a backtest that shows a smooth, rising equity curve?
- It rests on 9 trades taken in one calm month. Nine trades from one kind of market is mostly luck. The smooth line says little about how the rule behaves elsewhere.
- A test ends up 40%, but along the way the account fell 55% from its peak. What is the honest read?
- The drawdown may make it unusable, because few people hold on through a 55% fall. A result you would have abandoned at the bottom is a result you never collect.
Common questions
- What is backtesting in simple terms?
- Backtesting is replaying a fixed set of trading rules over past price data to see how those rules would have behaved. You define the entries, exits, and risk, then step through history bar by bar and collect the results.
- Does a good backtest predict future profit?
- No. A backtest describes the past only. It can tell you whether an idea ever had structure, but it cannot promise the same behavior will repeat, because future conditions and your own execution will differ.
- Why do so many backtests fail when traded live?
- Common reasons include too few trades, rules tuned to fit past noise rather than a real pattern, and real-world costs like fees and slippage that the simulation ignored. Honest evaluation guards against all three.
Terms defined in this lesson
Continue
- Next: Why a strategy screenshot proves almost nothing
- Sample size and why ten trades mean nothing
- Turning an idea into a testable rule set
- Look-ahead bias: when a backtest sees the future
- Backtest transaction costs: commissions, spread and slippage
- Backtesting and Research track
- All Agenticks lessons
- Trading glossary
Sources
- Investopedia. (n.d.). Backtesting. Investopedia.
- Investopedia. (n.d.). How to calculate trade expectancy. Investopedia.
- Investopedia. (n.d.). Drawdown. Investopedia.
Written and reviewed by the Agenticks Learn editorial team. How we write and check lessons.
Agenticks Learn is general education. It is not financial, investment, tax or legal advice, it does not take your situation into account, and nothing on it is a recommendation to buy, sell or hold any security or to open any account. Examples use illustrative numbers. Investing involves risk, including losing money you put in, and past performance does not predict future results. Tax rules and limits change; the official sources linked in each lesson are the final word.