How Do You Backtest a Forex Strategy Properly?

Forex · Published · By the UXS editorial team

Direct answer

Backtesting in brief

To backtest a forex strategy, write rules precise enough that two people would take the same trades, apply them to a long stretch of historical data trade by trade (manually or in software), include spread, commission and swap, and record every result in R multiples. Then test on data you did not use to design the rules. The main traps are look-ahead bias, overfitting to one period and ignoring costs, all of which make backtests look better than live trading.

  • Rules must be exact: entry, stop, target, filters, size
  • Include spread, commission and swap in every trade
  • Keep an out-of-sample period you never used to tune the rules
  • Measure expectancy in R and the worst losing streak, not just win rate

Updated November 10, 2026 · Sources checked November 10, 2026

A backtest is a rehearsal on old data. Done carefully it filters out bad ideas cheaply; done carelessly it builds confidence in a strategy that never had an edge.

What people on X are asking

In June 2025 one trader asked experienced traders how they backtest a specific setup, and another asked a successful trader whether he backtests with a rewind (replay) tool. In July a reply asked how you backtest on demo. The method below works with chart replay, spreadsheets or code.

The fact-checked answer

Step 1: rules you cannot argue with. Write the entry trigger, stop placement, target or exit rule, filters (session, trend, news) and position size. If a rule needs judgement ("strong candle"), define it numerically or accept that results will vary between testers.

Step 2: enough data and enough trades. Use several years, including different conditions: trends, ranges, high and low volatility. A few dozen trades say very little; many traders aim for at least 100 before drawing conclusions. Daily reference rates such as FRED's EUR/USD series show long regimes, but intraday strategies need intraday data with realistic bid/ask prices.

Step 3: costs. Deduct the spread on every trade, commission if your account charges it, and swap for overnight holds. On short-term systems costs are often the difference between profit and loss; see what the spread costs.

Step 4: record in R. Express each result as a multiple of the risk (R). That makes results independent of account size and lets you compute expectancy: average R per trade. Our win rate vs expectancy page shows the formula.

Step 5: out-of-sample and forward test. Split the data: design on one part, test on another you have not looked at. Then trade it on demo or very small size before committing; the comparison is covered in backtesting vs forward testing.

Biases that inflate backtest results

Summary by UXS of standard backtesting pitfalls. Tap a column header to sort.

Look-aheadUsing information not available at the time (e.g. the day's close at noon)Only act on completed bars
OverfittingRules tuned until the past looks perfectFewer parameters; out-of-sample test
Cherry-pickingTesting only the period where the idea workedFixed, long test window chosen in advance
Cost blindnessIgnoring spread, commission and swapDeduct realistic costs per trade
Execution optimismAssuming fills at exact levels during spikesAdd slippage on stops, especially around news
Small sample30 trades taken as proofCollect 100+ trades and look at streaks

UXS decision diagram

Is my backtest ready to trade on demo?

Is my backtest ready to trade on demo?Are all rules written soanother person would takethe same trades?NoTighten therules firstYesDoes the test includespread, commission andswap?NoRe-run withcostsYesAre there at least about100 trades acrossdifferent marketconditions?NoExtend the testperiodYesIs expectancy stillpositive on data not usedfor design?NoThe edge isprobablyoverfittingYesForward test on demo ortiny size and compareresults with the backtest
Text version of the diagram
  1. Are all rules written so another person would take the same trades? If no: Tighten the rules first
  2. Does the test include spread, commission and swap? If no: Re-run with costs
  3. Are there at least about 100 trades across different market conditions? If no: Extend the test period
  4. Is expectancy still positive on data not used for design? If no: The edge is probably overfitting
  5. Otherwise: Forward test on demo or tiny size and compare results with the backtest

Diagram drawn by UXS. A simplified decision aid for education, not a recommendation.

Expect live results to be worse. Even honest backtests miss emotion, missed entries and changing conditions. A common rule of thumb is to treat the backtest as a ceiling.

Free PDF

Manual backtest log (PDF)

One row per trade. Record costs and R so totals are comparable across strategies.

Strategy

#DateDirectionEntryStopExitCosts (pips)Result (R)

Summary

Fill-in fields in the PDF: Strategy name and version; Pair, timeframe and test period; Entry, stop and exit rules (short form); Trades / win rate / average win R / average loss R; Expectancy (average R per trade); Longest losing streak and largest drawdown (R); Out-of-sample result.

Download the PDF (44 KB, made by UXS, no sign-up)

Look at the bad stretches, not only the total. Two strategies with the same final profit can feel very different to trade. Record the longest losing streak, the deepest drawdown in R and how many weeks the equity curve spent below a previous high. If the worst run in the test would have breached a prop firm's limit or made you abandon the plan, the strategy needs smaller size or different rules before it is tradeable.

Even a careful test can mislead; see why strategies that work in backtests fail in live trading.

Common mistakes

  • Changing rules mid-test after a losing streak.
  • Testing on a mid-price chart and ignoring bid/ask.
  • Judging by win rate alone.
  • Assuming the next year will look like the test period.

FAQ

How many trades do I need in a backtest?

There is no fixed number, but under about 100 trades the results are heavily influenced by luck.

Is manual backtesting worth it?

Yes for discretionary setups; it is slower than code but teaches pattern recognition. Keep rules strict.

What is out-of-sample testing?

Testing on data you did not use while designing or tuning the rules, to check the edge is not overfitted.

Should I include swap in a backtest?

Yes for trades held overnight; on carry-heavy pairs it can change the result.

Why do my live results differ from the backtest?

Costs, slippage, missed trades, emotions and changing market conditions all reduce live performance.

What is a good expectancy?

Any reliably positive expectancy after costs is a starting point; the size of drawdowns decides whether it is tradeable.

Sources

Facts checked November 10, 2026. X posts are cited as evidence of the question, not of the answer.