Backtesting basics

How to Backtest a Forex Strategy: 5 Steps for Beginners

Published Updated ForeXpert team日本語で読む

To backtest a forex strategy, you write down your rules, fix the scope of the test, step through a past chart one bar at a time, log every trade, and review the numbers before changing anything. Two habits matter more than any tool: never look ahead on the chart, and record whether each trade actually followed your rules.

This guide explains how to backtest a forex strategy by hand, how to read the results (win rate, profit factor, maximum drawdown and more), and the mistakes that make a backtest look better than it really is. At the end, we show how to practice on historical charts from your phone.

What is backtesting in forex?

Backtesting means running your trading rules on past price data to see how they would have performed. It costs no real money, and it shows you, in numbers, where your rules hold up and where they break down.

There are two ways to do it.

Type How it works Best for
Manual backtesting Step through a past chart, decide each trade yourself and log it Discretionary traders who want to test their rules and their decision-making
Automated backtesting Turn the rules into code and let software run them over the data Rule sets that can be written entirely as formulas

This guide covers manual backtesting. Discretionary rules usually include judgments such as "the trend is clear". Stepping through the chart yourself tests those judgments along with the rules.

Manual backtesting is also practice. After you have made the same kind of decision dozens or hundreds of times, you hesitate less at the moment of entry and at the stop loss.

What to decide before you start

Whether a backtest is useful is decided before the first trade. You need two things: your rules and the scope of the test.

Write down your trading rules

Write the rules in your head down so clearly that another trader would make the same decisions. At a minimum, decide:

  • Entry conditions: what setup makes you buy or sell
  • Stop loss: where you exit if price moves against you (for example, just beyond the recent swing low)
  • Take profit: where you exit with a gain (for example, 1.5 times the stop distance)
  • When not to trade: around major economic releases, when the market barely moves, and so on

Once the stop is defined, also decide what share of your balance one loss may cost, so every trade in the test uses consistent sizing. Our position size calculator works out the size from your balance, risk per trade and stop distance.

If a rule still reads like "it looks like it will go up", you will decide differently on different days. Then you can no longer tell whether the results come from the rules or from your mood.

Choose a currency pair, timeframe and period

Start with one currency pair and one timeframe. If you test too much at once and the results are poor, it is hard to find out why.

  • Currency pair: the pair you actually plan to trade
  • Timeframe: the chart you make decisions on (15-minute, 1-hour and so on). If your rules check a higher timeframe for direction, decide that one too
  • Period: long enough to include rising, falling and sideways markets. Start with a few months to a year, then test another period later

How to backtest a forex strategy in 5 steps

Once you are ready, work through these five steps.

The five steps to backtest a forex strategy: write down your rules, fix the scope, step through the chart bar by bar, log every trade, review the numbers and change one thing
Figure: 5 steps to backtest a forex strategy

1. Write down your rules

Keep your written rules where you can see them during the test. Even if you want to change a rule halfway through, leave it alone until this round of testing is finished. Otherwise you will not know which version of the rules produced the results.

2. Fix the scope

Pick the pair, timeframe and period, and open the chart at the start date. Do not look at anything after that date.

3. Step through the chart bar by bar

Move the chart forward one candle at a time and place a trade only when your conditions are met. Set the stop loss and take profit when you enter, not later.

The biggest trap here is looking ahead. If you scroll through the whole chart first and then pick the spots where a trade "would have worked", you count trades you could never have taken in real time, and the results look far better than your actual skill.

4. Log every trade

After each trade, record:

  • Entry and exit time and price
  • Long or short, and the profit or loss
  • Why you entered (which conditions were met)
  • Whether the trade followed your rules, including the ones where you hesitated or broke a rule

That last column is what makes manual backtesting so useful. When you compare rule-following trades with the rest, you can see whether a problem lies in the rules themselves or in how consistently you apply them.

5. Review the numbers and change one thing

Once you have enough trades, check them against the metrics in the next section. If you find something to fix, change only one thing at a time and test again. If you change several things together, you cannot tell which change made the difference.

Then test the revised rules on a different period. Rules that only improved on the period you tuned them on may simply fit that stretch of price history.

How to read your backtest results

If you still hold a position when the test ends, record its unrealized P&L separately. See how to report open positions at the end of a backtest for a worked example.

Do not judge a strategy by win rate alone. A high win rate can still lose money if the losses are large. Look at these together:

Metric What it means What to look for
Win rate Share of trades that made money Read it together with average win and average loss
Profit factor Gross profit ÷ gross loss Above 1 means the period was profitable overall
Maximum drawdown Largest fall from a balance peak to a later low Whether you could live through a fall that size
Average win and average loss Typical size of a winning and a losing trade Their ratio is the risk-reward ratio
Max consecutive losses Longest losing streak Whether you would keep following the rules through it
Number of trades How many trades the test includes Too few and luck dominates

For a closer look at these measures, read our guides to trading expectancy and maximum drawdown.

To see how deep a losing streak could cut into your balance at different levels of risk per trade, try our risk of ruin calculator.

Our guides to profit factor and the risk-reward ratio explain how to investigate aggregate results and distinguish planned exits from realized averages.

A worked example

Suppose a test ends like this (numbers made up for illustration):

  • 100 trades: 45 wins, 55 losses
  • Average win: $120, average loss: $80

The win rate is 45%. Gross profit is 45 × $120 = $5,400 and gross loss is 55 × $80 = $4,400, so the profit factor is 5,400 ÷ 4,400 ≈ 1.23. The average result per trade (expectancy) is ($5,400 − $4,400) ÷ 100 = $10.

The strategy wins less than half the time, yet it is profitable over the period because the average win is 1.5 times the average loss. The reverse also happens: with a 70% win rate, a strategy still loses money if its average loss is three times its average win. Always read win rate and trade size together.

More trades make results more reliable

Ten trades can easily be a lucky streak. We suggest collecting around 100 trades before you judge a strategy. If your setup appears rarely, extend the test period to get there.

Keep in mind that a backtest shows how rules performed on past prices. It does not guarantee future results. Live trading adds widening spreads, slippage and the pressure of real money. Use backtesting as a tool to find and fix weaknesses in your rules.

Common backtesting mistakes to avoid

Five mistakes catch most beginners:

  1. Looking ahead: deciding with future candles in view makes results look better than your skill. Step forward one bar at a time and decide with only what you could see then
  2. Judging too early: a handful of trades says almost nothing about a strategy
  3. Testing only a convenient period: a clean trending stretch hides how the rules do in a sideways market. Test several periods
  4. Over-fitting the rules: adding a filter for every losing trade makes the test period look great and the next period disappointing
  5. Ignoring costs: leaving out the spread and other costs widens the gap with live trading, especially for strategies that trade often

All five make a backtest look better than reality. The better your results look, the more carefully you should check for them.

The backtesting-cost guide also explains how to identify missing charges without deducting an embedded spread twice.

How to practice backtesting on your phone

You can backtest by hand with desktop software or a chart replay feature. If you would rather work in short sessions, on a commute or before bed, a phone app is another option.

Our app, ForeXpert, is an iOS app for practicing trades on historical charts, one bar at a time. Here is how it maps to the five steps:

  • Fix the scope: create a backtest by choosing a currency pair (26 available), a timeframe (8, from 1-minute to weekly) and a period
  • Step through the chart: move the chart forward bar by bar, place market, limit and stop orders, and set a stop loss and take profit. You can show several timeframes side by side
  • Review the numbers: check win rate, profit factor, maximum drawdown, average win and loss, max consecutive losses and more on the stats screen
The ForeXpert chart screen showing an AUDUSD 15-minute chart above a 4-hour chart, with an Order button and a play button for stepping forward
The ForeXpert chart screen with 15-minute and 4-hour charts side by side (demo data)

Every currency pair and period is available on the free plan (up to three new backtests a month), so try the five steps in this guide on a single currency pair.

Frequently asked questions

How many trades do I need in a backtest?

There is no fixed number, but ten or so is far too few. Aim for around 100, and extend the test period if your setup does not appear often.

Should I backtest manually or automatically?

If every rule can be written as a formula, automated testing covers more data in less time. If your rules include chart-reading judgments, manual testing checks both the rules and your decisions.

If my backtest is profitable, will I make money trading live?

Not necessarily. A backtest reflects past prices and does not guarantee future results. Live trading adds costs, slippage and emotion. Keep testing with small positions or a demo account, and keep logging and reviewing your trades.

Summary

To backtest a forex strategy:

  1. Write down your trading rules in words that leave no doubt
  2. Fix the currency pair, timeframe and period
  3. Step through the past chart bar by bar and trade without looking ahead
  4. Log every trade, including whether it followed your rules
  5. Review win rate, profit factor and maximum drawdown together, change one thing at a time, and retest on another period

Start by writing the rules you trade (or want to try) on paper. You will probably find a condition you have not fully decided yet.