Backtesting Guide

How to Backtest a Trading Strategy

Backtesting a trading strategy is how you find out whether an idea has an edge before it costs you real money. Done loosely it just confirms what you already hoped; done properly it gives you a win rate, an expectancy, and a drawdown you can actually trust. Here is the step-by-step process — and the free tool to run it.

To backtest a trading strategy means to run its rules across historical price and record what would have happened — enough times that the result is a measurement, not an anecdote. The goal is a sample large and honest enough that the numbers reflect the strategy, not luck and not your bias. Five steps get you there.

Step 1 — Write the rules down first

Before you look at a single chart, define the strategy precisely: what triggers an entry, where the stop goes, where the target goes, and what closes the trade early. If the rules live only in your head, you will unconsciously bend them to fit each chart and the backtest becomes worthless. Written rules make every trade repeatable — the whole point of testing properly.

Step 2 — Choose the instrument and timeframe

Test the strategy on the market and timeframe it is actually meant to trade. A scalping rule set belongs on M1–M15; a swing strategy belongs on H4–D1. Load real historical data for that instrument — and if the strategy is meant to be general, plan to repeat the test on a few different markets rather than assuming one result transfers.

Step 3 — Replay the chart and take every trade

Step the chart forward one bar at a time and take every trade your rules allow — including the ugly ones you would rather skip. This is where most backtests go wrong: quietly passing on the setups that "didn't feel right" inflates the win rate and hides the strategy's real behaviour. Bar-by-bar manual backtesting keeps you honest because you can't see the future bars.

Beware curve-fitting and look-ahead bias: if you tweak the rules after seeing the result until the equity curve looks perfect, you have fitted the strategy to the past, not found an edge. Test the rules as written, then change them once and re-test on fresh data — never mid-sample.

Step 4 — Build a large enough sample

A handful of trades proves nothing. Aim for at least 50–100 trades across different conditions — trends, ranges, quiet and volatile periods — so a couple of lucky winners can't carry the result. This is exactly why manual backtesting beats waiting for live trades: you can build a 60-trade sample in an afternoon instead of a year.

Step 5 — Read the metrics together, not win rate alone

Win rate in isolation is the most over-weighted number in trading. Read the full picture:

  • Win rate + risk-reward — a 40% win rate at 1:2 is profitable; a 60% win rate at 1:0.5 is not.
  • Expectancy — the average dollar (or R) you make per trade; this is the real edge.
  • Profit factor — gross profit divided by gross loss; above ~1.3 is a decent start.
  • Max drawdown — the deepest the account fell; the pain you have to survive to collect the edge.

A good backtester computes all of these for you and draws the equity curve, so you read the strategy the way a risk desk would rather than tallying a spreadsheet by hand.

Backtest a strategy free, no code

FxBacktest runs the whole process in the browser for free. Pick an instrument and timeframe, replay the chart bar by bar, place buy and sell trades with draggable stop and target, and the lot is auto-sized to a fixed risk percentage. Every trade is logged, and the end-of-session report totals your win rate, expectancy, profit factor, and drawdown automatically — no Pine Script, no download, no card. It works for a discretionary strategy that a code-only tester can't measure.

A worked example: 60 trades on EURUSD H1

Abstract steps are easy to nod along to, so here is the same process with numbers attached. The strategy: buy the pullback to the 20 EMA in an uptrend, stop below the swing low, target twice the stop distance.

  • Sample: 60 trades on EURUSD H1, spanning a trending stretch, a choppy range, and one high-volatility news week.
  • Result: 24 winners, 36 losers — a 40% win rate, which sounds like failure until you read it beside the risk-reward.
  • The maths: at 1:2, the 24 winners return 48R and the 36 losers cost 36R. Net +12R across 60 trades.
  • Expectancy: 12R divided by 60 trades = +0.2R per trade. Risking 1% per trade, that is roughly 0.2% of the account earned per trade taken.
  • Max drawdown: a run of 7 straight losses mid-sample took the equity curve down 7R. That is the number that decides whether you can actually trade this.

Note what the sample exposes that a 10-trade test would have hidden entirely: the seven-loss streak. A strategy with a positive expectancy you cannot psychologically survive is not a tradable strategy, and only a large enough sample surfaces that.

What a good backtest result actually looks like

There is no single passing grade, but these ranges separate a result worth forward-testing from one worth discarding.

MetricWeakWorth testing furtherStrong
Sample sizeUnder 30 trades50-100 trades200+ trades
ExpectancyNegative or ~0R+0.1R to +0.3RAbove +0.3R
Profit factorBelow 1.01.3 to 1.6Above 1.6
Max drawdownDeeper than you would sit throughUnder 15% of accountUnder 10% of account
Longest losing streakUnknown - sample too smallMeasured and survivableMeasured and comfortable

Be suspicious of results that look too good. A profit factor above 3 on a small sample almost always means the rules were bent, the sample was cherry-picked from a single favourable regime, or the strategy was curve-fitted to the data you tested on.

Manual vs automated backtesting a strategy

Both approaches answer the same question, but they suit different rule sets — and picking the wrong one wastes weeks.

  • Automated suits fully mechanical rules with no judgement calls. You write the strategy in code, run it across years of history in seconds, and can optimise parameters quickly. The catch: it only tests what you can express in code, and fast optimisation makes curve-fitting almost effortless.
  • Manual suits discretionary rules — anything involving structure, context, or "only in this kind of market". You replay the chart bar by bar and cannot see the future, so the test reflects the decisions you would genuinely have made in the moment.

Most retail strategies are partly discretionary even when the trader believes they are mechanical. If you cannot hand your rules to a stranger and have them take the identical trades, the strategy has judgement in it and needs manual testing.

Five mistakes that make a backtest worthless

  1. Skipping the ugly setups. Passing on trades that "obviously" would have lost is the single most common way traders inflate a win rate without noticing.
  2. Seeing the future bars. Scrolling a static chart lets your eye register what happened next. Bar-by-bar replay is the only way to remove this.
  3. Testing one market regime. A trend-following strategy tested only across a clean trend will look extraordinary and then fail the moment the market ranges.
  4. Ignoring costs. Spread and commission turn many marginal scalping edges negative. A backtest without costs applied measures a strategy you cannot actually trade.
  5. Re-tuning mid-sample. Adjusting the rules halfway through because the results disappoint means your sample now tests two different strategies, and neither honestly.

Measured: why the years you test decide the answer

The most common way a backtest lies is not a coding error — it is testing a single volatility regime and reading the result as a permanent property of the strategy. Here is the size of that effect, measured on 3,440 EURUSD daily bars:

YearEURUSD avg daily rangevs. the 11-year meanGBPUSD
2015107 pips+51%107 pips
201679 pips+11%131 pips
201947 pips-34%88 pips
202154 pips-24%79 pips
202288 pips+24%116 pips
202453 pips-25%68 pips
2015-2025 mean71 pips95 pips

EURUSD's average day was 107 pips in 2015 and 47 pips in 2019 — the same instrument, less than half the movement. A breakout strategy tested only on 2015 looks excellent; the identical rules on 2019 barely clear the spread. Neither result is wrong, and neither is the strategy's true expectancy.

Three rules follow directly from this:

  • Never test one continuous recent window. Split the sample across a high-volatility year and a low one and compare the two reports separately, not merged.
  • Watch the pair, not just the strategy. 2016 was quiet for EURUSD (79 pips) and the loudest year in the decade for GBPUSD (131 pips, the Brexit referendum). Portfolio results hide this; per-instrument results expose it.
  • Report the range, not a single number. "Profit factor 1.4" means little. "Profit factor 1.9 in 2015, 1.1 in 2019" is a strategy you can actually plan around.

Regulators make the same point about simulated results in general — see the CFTC rule cited below, which requires hypothetical performance to carry a warning that such programs are "designed with the benefit of hindsight". That is precisely the failure mode a single-regime backtest produces.

Computed 2026-08-27 from the FxBacktest tick-derived OHLC archive: 3,440 EURUSD and 3,438 GBPUSD daily bars, 2015-2025. "Avg daily range" is the mean of each day’s high minus low, in pips.

Backtesting a strategy — FAQ

How many trades do I need to backtest a strategy?

Aim for at least 50 to 100 trades across different market conditions before you trust the numbers. Fewer than that and a couple of lucky winners can make a losing strategy look profitable. The more trades in the sample, the more reliable the win rate and expectancy become.

What metrics matter most when backtesting a trading strategy?

Win rate on its own is misleading. Read it beside risk-reward, expectancy (average profit per trade), profit factor, and maximum drawdown. A strategy with a 40% win rate at 1:2 risk-reward is profitable; a 60% win rate at 1:0.5 is not. Expectancy and drawdown together tell you whether the edge is real and survivable.

Can I backtest a trading strategy for free?

Yes. FxBacktest is a free browser-based backtester: replay historical charts bar by bar, place manual trades with stop and target, and get a full report of win rate, expectancy, and drawdown — no download, no code, and no credit card required.

How long does it take to backtest a trading strategy?

A 50 to 100 trade sample on an hourly chart typically takes two to four hours of focused chart replay. That is dramatically faster than forward testing the same strategy live, which would take months to produce the same number of trades.

How far back should I backtest a strategy?

Far enough to cover several different market conditions rather than a fixed number of years. One to two years of data on an intraday timeframe usually spans trending, ranging, quiet, and volatile periods. Testing only the most recent few months risks measuring a single regime that will not repeat.

What is the difference between manual and automated backtesting?

Automated backtesting runs a strategy written in code across history in seconds, but only works for fully mechanical rules. Manual backtesting means replaying the chart and taking each trade by hand, which is the only honest way to test a discretionary strategy where judgement is part of the entry.

Sources

Risk disclaimerTrading foreign exchange, CFDs, and other leveraged products carries a high level of risk and is not suitable for every investor — losses can exceed your deposits. Everything on this page is educational content, not financial advice. Backtest and simulator results are hypothetical: they do not represent live trading and past performance does not guarantee future results.