Skip to content
pipdojo.com

Study desk

Your progress

White belt · Current belt

Lessons
0/25
Day streak
0
XP
0
Next lessonWhat is a pip?

Day streak and XP, stored on this device only

Study language

Pages switch to this language; your progress stays on this device.

Guide · 6 min read

Walk-Forward Testing: How to Check Whether a Forex Strategy Holds Up on New Data

A concise guide: split EUR/USD history into in-sample and out-of-sample blocks, freeze parameters, roll windows forward, and judge pooled out-of-sample results, not one optimized backtest.

Written by
Leena Forex curriculum team
Education, not advice
Nothing here is a recommendation to trade
Walk-Forward Testing: How to Check a Forex Strategy on New Data (EUR/USD Example)

Key takeaways

  • Walk-forward testing optimizes on one block, freezes settings, then tests on later unseen data.
  • Pool out-of-sample blocks and judge them together, not one optimized backtest.
  • Read net profit, expectancy, R-multiples, drawdown, win rate, trade count and stability together.
  • Look-ahead bias, leakage, thin data and missing costs mislead; editing rules after results also does.
  • Walk-forward testing makes overfitting visible but cannot promise future profit.

What it is, and why a good backtest can fail on new data

Walk-forward testing validates a strategy by optimizing it on one block of past prices, freezing settings, and testing that frozen result on the next block.

  • In-sample (IS) data is the block you may tune on.
  • Out-of-sample (OOS) data is later data used only for testing.
  • Walk-forward optimization is the automated process of rolling these windows forward, optimizing on each IS block, and testing on the following OOS block.

A backtest can look excellent and fail on new data through overfitting: the rules latched onto noise. Walk-forward testing does not remove overfitting; it makes it visible.

The roll: 12 months in, 3 months out, then step forward

Use hypothetical hourly EUR/USD data from Month 1 to Month 24, with a 12-month IS window, a 3-month OOS window and a 3-month step. This is an illustration, not a standard.

  • Optimize on Months 1–12, freeze, run unchanged on Months 13–15, record.
  • Roll both windows forward three months. IS becomes Months 4–15, OOS Months 16–18. Re-optimize on the new IS block only, freeze, test.
  • Repeat: IS Months 7–18, OOS Months 19–21.
  • Repeat: IS Months 10–21, OOS Months 22–24.

Overlapping IS windows are normal in rolling walk-forward testing. An earlier OOS block may later become part of a later IS window, but each OOS block must not influence the parameters tested on that same block.

Worked example: a EUR/USD moving average crossover

Hypothetical example

Rule: a reversal system on EUR/USD. Buy (or close a short and go long) when the 10-period simple moving average (SMA), the average of the last N closes, crosses above the 40-period SMA; sell (or close a long and go short) when the 10-period SMA crosses below the 40-period SMA. An opposite crossover therefore closes any existing position and opens a new position in the opposite direction, unless the fixed stop-loss has already closed the trade. Execute the crossover at the next available price, often the next bar's open, not at the close itself.

Every new position uses a fixed 20-pip stop-loss. If the stop-loss is hit, the position closes and the strategy stays flat until a new crossover signal occurs; it does not re-enter immediately at the stop. The example assumes a USD-denominated account and approximately $1 per pip for 0.10 lots of EUR/USD under the stated contract assumptions. At 0.10 lots (10,000 units), a 20-pip stop-loss therefore risks about $20.

R is risk per trade: 20 pips × about $1.00 per pip = $20.

Grid

Fast SMA 5, 10, 15 or 20; slow SMA 30, 40, 50 or 60.

  • Sixteen combinations, evaluated on IS only using a predefined performance metric (for example, net return after costs), and the same selection criterion is applied consistently to every combination.

Walk 1 IS (Months 1–12)

  • Best 10/40.
  • Hypothetical +$410 after costs over 96 trades.
  • Freeze 10/40.

Walk 1 OOS (Months 13–15), untouched

  • 18 trades: eight winners averaging 26 pips, ten losers averaging 14 pips.
  • Gross: (8 × 26) − (10 × 14) = +68 pips.
  • Costs at 1.5 pips per round trip: 18 × 1.5 = 27 pips.
  • Net: 41 pips, about $41.

Expectancy

  • Win rate 44.4%.
  • Average net win $24.50.
  • Average net loss $15.50.
  • (0.444 × 24.50) − (0.556 × 15.50) = $2.28 per trade, about 0.11R.

This is the first OOS block. The walk-forward continues with three more OOS blocks, pooled in the next section.

Combining out-of-sample blocks and reading metrics

Pool every OOS trade into one chronological sequence and calculate metrics once; never re-optimize inside it.

In this hypothetical illustration, the pooled four-block results are 75 trades, net +$78, and expectancy about $1.04 per trade (0.05R); these are illustrative figures, not actual results. Maximum drawdown must come from the complete chronological OOS equity curve, not from adding block drawdowns.

Read together:

  • Net profit after costs.
  • Expectancy.
  • R-multiples, where +$24.50 on $20 risk is about +1.23R and −$15.50 is about −0.78R.
  • Maximum drawdown.
  • Win rate with average win and loss.
  • Trade count, since 75 is thin.
  • Parameter stability.
  • Dispersion, because in this hypothetical illustration the four block results range from −$63 to +$88.

Backtesting, walk-forward and forward testing are different

Ordinary backtesting tests a rule on historical data. Bias occurs when the same data develops and evaluates the strategy: you tune until it looks good, then report that fit as evidence.

  • Walk-forward testing separates building from judging, though every OOS block is still past data.
  • Demo forward testing runs it on a demo account at live prices, testing real spreads, fills, platform behavior and discipline.

A clean walk-forward does not prove live execution will match it. Over-testing is a trap: try 500 combinations and the best is partly luck. Bailey and coauthors set out this problem in “The Probability of Backtest Overfitting” (SSRN). Keep the grid small. If you change a rule after seeing results, those OOS data become development data; log it and restart.

Traps: look-ahead bias, leakage, thin data, costs

  • Look-ahead bias uses information unavailable at decision time. A moving-average crossover is confirmed at bar close; execute a close signal at the next price, often the next bar's open, not the close itself. Check platform timestamps.
  • Data leakage occurs when information from the same OOS period influences the parameters being tested on it, for example if that OOS block is used to choose or adjust settings. Overlapping in-sample windows are normal in rolling walk-forward testing, and an earlier OOS block may later become part of a later IS window; that alone is not leakage if each OOS block is untouched when its own frozen parameters are tested.
  • Thin data means few trades per block; small samples are less conclusive, and no universal minimum trade count exists.
  • Costs matter: in Walk 1, 1.5 pips per round trip removed 27 pips from 68 gross. Charge spread, commission, slippage and swap on both runs.

If weak, ask whether losses were concentrated, parameters wandered, a regime was missing, or costs explained the gap. Then simplify, shrink the grid, lengthen IS, or shelve it; if a modest or inconsistent edge remains, validate further with demo forward testing before considering live trading.

Checklist and takeaway

  • Write the rule: entry, exit, stop, target, size, session.
  • Fix IS length, OOS length, step and a small grid before results.
  • Freeze parameters at each OOS start.
  • Use bar-close logic; execute a bar-close signal at the next available price, often the next bar's open.
  • Charge spread, commission, slippage and swap in both runs.
  • Log dates, parameters, trades, net profit, expectancy in R, pooled-curve drawdown and win rate.
  • Pool OOS trades by date and judge the combined result, not the best block.
  • If you change a rule after seeing OOS results, restart and record the discarded run.
  • Follow with a demo forward test before risking money.

Takeaway

Walk-forward testing is more honest than one optimized backtest, but it does not eliminate overfitting or predict EUR/USD. A modest or inconsistent edge, especially with only 75 out-of-sample trades in the example, requires further validation through demo forward testing before considering live trading.

Read the primary source

Check it at the regulator, not at us

Screenshots of the official pages behind the rules in this guide. Open them yourself — the regulator’s own words always beat a summary of them.

Investor.gov's explanation of margin accounts
Investor.gov's explanation of margin accountsOpen the original
The CFTC's forex fraud advisory for consumers
The CFTC's forex fraud advisory for consumersOpen the original

Frequently asked

How long should in-sample and out-of-sample periods be?Long enough to show behavior and trades. A 12-month IS and 3-month OOS rolled quarterly is an illustration, not a standard.
How many walk-forward steps do I need?No universal minimum. Prefer a few longer blocks over many tiny ones.
Can I automate walk-forward testing?Yes. Automate the roll, record per-block metrics, and verify timestamps and bar-close logic.
Should spreads, commissions, slippage and swap be included?Always. In the example, 1.5 pips per round trip removed 27 of 68 gross pips; leaving costs out can flatter a losing rule.
What if my strategy fails most out-of-sample blocks?Treat it as information. Check concentrated losses, parameter drift, missing regime, or costs. Then simplify, shrink the grid, lengthen IS, or shelve it. Do not re-run until it looks good.

Sources

Where this came from

  1. QuantConnect: Walk-Forward Optimizationquantconnect.com
  2. Bailey, Borwein, López de Prado and Zhu: The Probability of Backtest Overfitting (SSRN)papers.ssrn.com

Written by Leena

Forex curriculum team. We write structured, plain-English forex education for people learning from scratch. Understanding first, always — and never financial advice. The course itself lives in the curriculum.

Keep reading