How to Backtest a Trading Strategy: A Step-by-Step Guide

Last updated July 29, 2026
Table of Contents

You have a trading idea that looks brilliant on a live chart, but no idea whether it actually makes money or just feels like it should. Backtesting is how you find out before you risk a cent. You apply your exact entry, exit and risk rules to old price data and measure how they would have performed. This guide shows you how to run a clean backtest by hand, read the four numbers that matter, and prove the idea on a free demo before you go live.

TL;DR / Quick insight: To backtest a strategy, write your idea as mechanical rules (entry, exit, stop, position size), replay historical price one bar at a time while hiding the future, log every trade, then compute win rate, average R, max drawdown and expectancy. A positive backtest is a hypothesis, not a promise. Real spreads and slippage eat into paper results. The safe path runs backtest, then forward-test on a free demo, then go live small.

You do not need a paid tool. A price chart, a bar-replay function and a spreadsheet are enough to backtest any strategy for free. A backtest rehearses your rules against the past. It estimates whether your strategy had an edge, but it does not predict the future.

What backtesting is, and what it cannot tell you

Volity infographic card contrasting what a backtest can tell you (a rough edge, rule discipline, expectancy) against what it cannot (guarantee future results or remove real spread and slippage costs).

Backtesting takes fixed rules – buy here, sell there, stop here – and applies them to historical price data to see how they would have performed. It gives you evidence, not certainty.

What it cannot tell you matters just as much. Past performance is not future results. Real costs bite. Live trading carries spreads (the gap between buy and sell price), commissions and slippage (when your order fills at a worse price than expected), so a test that ignores them flatters itself. Rules tuned for a calm market can also fall apart in a choppy one.

Before you start, write one honest sentence on what your backtest will prove (an edge on this market) and what it will not (that the future repeats).

Define rules you can actually test

Volity checklist board titled Make your rules mechanical with five ticked items: market and timeframe, entry trigger, exit or take-profit, stop-loss and position size.

A backtest is only as good as its rules. “Buy when it looks strong” cannot be tested, because two people would mark different trades. You need rules so mechanical that a stranger could produce the same trades. Pin down five things:

  • Market and timeframe – what you trade and on which candles, for example EUR/USD on the 1-hour chart.
  • Entry trigger – the precise condition that puts you in.
  • Exit or take-profit – where you close a winner.
  • Stop-loss – where you get out for a loss; this defines your risk per trade.
  • Position size – how much you risk per trade, ideally a fixed % of the account.

Write your strategy as a rule sheet a stranger could execute with no guessing. “I’d probably…” is not a rule yet.

Backtest by hand, step by step

Volity workflow diagram of manual backtesting in five numbered steps: pick a market and fixed window, hide the future with bar replay, apply rules bar by bar, log every trade, then tally the results.

Manual backtesting is slow, but doing it by hand trains your eye to spot setups in real time. The trade counts below are illustrative.

  1. Pick a market and a fixed historical window – one instrument and a defined stretch of past data, fixed upfront so you cannot cherry-pick.
  2. Hide the future. Use your chart’s bar-replay mode, which reveals price one candle at a time. This step matters most. Skip it and you will cheat.
  3. Scroll one bar at a time and watch for your entry condition.
  4. When a signal appears, log the trade – entry, stop, planned exit – before you reveal the outcome.
  5. Reveal the result and record the R. Move forward until the trade hits the stop or the exit, then note the win or loss and the R-multiple (how many times your risk you made or lost).
  6. Repeat across the sample (30-50 trades is a reasonable illustrative start) so luck cannot fool you.

Log every trade, winners and losers, in a journal. Do not skip losers or round near-misses up.

Compute the metrics that matter

Four numbers turn your journal into a verdict:

  • Win rate – the share of trades that won. 6 of 10 is 60%. A high win rate alone is not profit; small wins and big losses can still sink you.
  • Average R (reward-to-risk) – your average result in units of risk. Risk $100 to make $200 and a win is +2R, a loss -1R.
  • Max drawdown – the largest peak-to-trough drop in your account during the test. It shows whether you could stomach the strategy.
  • Expectancy – average profit per trade, (win% x average win) – (loss% x average loss). Positive means an edge; negative means the rules lost money.
Illustrative worked example (made-up numbers, not a claim):
50 trades, 40% win rate, average win +2R, average loss -1R, risk $100.
Expectancy = (0.40 x $200) – (0.60 x $100) = +$20 per trade.
Even with most trades losing, positive expectancy means an edge. These figures are illustrative only.

Compute all four and write one verdict – “positive edge” or “no edge” – based on expectancy. If it comes out negative, question the strategy, not the settings.

Avoid the two mistakes that wreck backtests

Two errors ruin more backtests than bad strategies do.

The first is overfitting: you adjust your rules until they fit one slice of history perfectly. The past looks flawless, but you have just memorised noise, and the strategy collapses on fresh data.

The second is look-ahead bias: you use information you would not have had in real time, like acting on a candle’s close before it closed. It makes paper results impossibly good, which is the reason you hide the future.

Two smaller traps remain: samples too small to mean anything, and ignoring costs. The guardrail is out-of-sample testing (walk-forward). You reserve data you never looked at, then run the finished strategy on it cold.

Re-run the strategy on a fresh out-of-sample window. If it falls apart, trust the cold result.

Move from backtest to demo to live

A positive backtest is a hypothesis, not a green light. The bridge to real money is forward-testing, where you run the same rules in live conditions without risking capital. A demo is a practice account that trades live prices with virtual money, so you feel real spreads, fills and timing at zero risk. Volity offers a free demo on every account tier. Real costs matter, so it helps that the Markets account is commission-free and Standard spreads start from 0.6 pip (a pip is the smallest standard price move in forex). SEE FEES AND ACCOUNT TYPES to factor them in.

Safe sequence:
Backtest → Out-of-sample re-run → Forward-test on a free demo (live conditions, no risk) → Go live small

TRY A FREE DEMO ACCOUNT, forward-test the same rules, and scale into live trading in small size only once it holds up. One Volity login covers shares, fractional shares, crypto and CFDs; if forex is your focus, the forex hub has the matching guides.

Run through the clean-backtest checklist

Before you trust a strategy with real money, tick every box. One unchecked box means you are guessing.

  • Rules written as mechanical if-this-then-that (entry, exit, stop, size), zero discretion.
  • A fixed window chosen before testing, not cherry-picked after.
  • The future hidden during the test (bar-replay, no peeking).
  • Real costs included: spreads, commissions and slippage.
  • An adequate sample, large enough that luck does not drive it.
  • All four metrics computed: win rate, average R, max drawdown, expectancy.
  • An out-of-sample re-run on data you never optimised.
  • Forward-tested on a free demo before real capital.

Keep this checklist beside your journal and refuse to fund a strategy that misses a box.

Ready to put a validated strategy to work? You can OPEN A VOLITY ACCOUNT and trade forex, shares, crypto and CFDs from one commission-free login. The trader education hub has the risk and journaling guides that make a backtest pay off.

Reviewed by: the Volity editorial desk (A. Bennett byline).
Data integrity: all formulas (expectancy, R-multiple, drawdown) are standard trading mathematics; every numeric example is labelled illustrative, not a forecast. Volity product facts (free demo on every tier, commission-free Markets account, spreads from 0.6 pip) are verified against Volity’s published account and fee docs, June 2026.

Related Volity guides

Frequently asked questions

What is backtesting in trading?

Backtesting applies your fixed entry, exit and risk rules to historical price data to see how they would have performed. It estimates whether a strategy had an edge – evidence, not a guarantee.

How many trades do you need to backtest a strategy?

Enough that one lucky or unlucky streak cannot drive the result – a meaningful sample, not a handful. Any specific number is a rule of thumb; bigger samples read more reliably.

How do I backtest a forex strategy specifically?

Use the same method on a currency pair and timeframe, for example EUR/USD on the 1-hour chart: mechanical rules, candle-by-candle replay, a logged journal, the four metrics. Apply realistic spread and rollover costs, then forward-test on a demo.

Why does expectancy matter more than win rate?

Expectancy, (win% x average win) – (loss% x average loss), is the average profit per trade. A strategy can win often yet lose money if its losses dwarf its wins, so positive expectancy is the clearest sign of a real edge.

Can you backtest a strategy for free?

Yes. You only need a price chart with bar-replay and a spreadsheet to log trades and compute the metrics by hand. To forward-test in live conditions, open a free Volity demo, available on every tier.

Is backtesting reliable?

It works as an estimate of edge, not a promise. It depends on a large enough sample, an out-of-sample re-run, and including real costs. Skip those and a backtest can flatter a strategy that fails live.

Sources

The guidance above draws on the following public sources.

Start Your Days Smarter!

One Wallet. Then Invest. Then Trade.

Volity is your all-in-one hub for money movement, market access, and financial clarity.

High-Risk Investment Notice:  Website information does not contain and should not be construed as containing investment advice, investment recommendations, or an offer or solicitation of any transaction in financial instruments. It has not been prepared in accordance with legal requirements designed to promote the independence of investment research, and it is not subject to any prohibition on dealing ahead of the dissemination of investment research. Nothing on this site should be read or construed as constituting advice on the part of Volity Trade or any of its affiliates, directors, officers, or employees.

Please note that content is a marketing communication. Before making investment decisions, you should seek out independent financial advisors to help you understand the risks.

Services are provided by Volity Trade Ltd, registered in Saint Lucia, with the number 2024-00059. You must be at least 18 years old to use the services.

Trading forex (foreign exchange) or CFDs (contracts for difference) on margin carries a high level of risk and may not be suitable for all investors. There is a possibility that you may sustain a loss equal to or greater than your entire investment. Therefore, you should not invest or risk money that you cannot afford to lose. The products are intended for retail, professional, and eligible counterparty clients. For clients who maintain account(s) with Volity Trade Ltd., retail clients could sustain a total loss of deposited funds but are not subject to subsequent payment obligations beyond the deposited funds. Professional and eligible counterparty clients could sustain losses in excess of deposits.

Volity is a trademark of Volity Capital L.L.C-FZ, registered in Dubai, U.A.E., with the number 2423068.
Volity Invest Ltd, number HE 452984, registered at Archiepiskopou Makariou III, 41, Floor 1, 1065, Lefkosia, Cyprus is acting as a payment agent of Volity Trade Ltd.

Volity Trade Ltd. is an introductory broker for UBK Markets Ltd. It offers execution and custody services for clients introduced by Volity. UBK Markets Ltd is authorised and regulated by the Cyprus Securities and Exchange Commission (CySEC), license number 186/12 and registered at 67, Spyrou Kyprianou Avenue, Kyriakides Business Center, 2nd Floor, CY-4003 Limassol, Cyprus.

Volity Trade Ltd. does not offer services to citizens/residents of certain jurisdictions, such as the United States, and is not intended for distribution to or use by any person in any country or jurisdiction where such distribution or use would be contrary to local law or regulation.

Copyright: © 2026 Volity Trade Ltd. All Rights reserved.