Walk-forward analysis is a way of testing a trading strategy on data it hasn’t seen: you optimize on one stretch of history, test the result as it is on the next stretch, move the window forward and repeat. What counts is the test stretches put together, not the optimization. MetaTrader 5 doesn’t do the whole thing, but its Forward setting does one of those passes, and by chaining several by hand you can build one. Here you’ll find what it is, a worked example with windows, the steps in MT5 and how to read the result. This is a guide, not a recommendation.
- What is walk-forward analysis? In-sample vs out-of-sample
- Backtest, out-of-sample test, walk-forward and forward test: the differences
- A worked example: rolling vs anchored walk-forward
- What is walk-forward efficiency (WFE)?
- How to do walk-forward analysis in MT5: the Forward setting
- How to read a walk-forward test, and where its limits are
- What AUREUM’s home page says about its validation
- Walk-forward analysis FAQ
What is walk-forward analysis? In-sample vs out-of-sample
A backtest applies a strategy to past prices to see what it would have done (what a backtest is and how to read it). The trouble starts when you optimize: you try many combinations of parameters on one stretch of history and keep the best. That combination has already seen the exam. Its result tells you what would have worked on that data, not what will work on other data: that’s overfitting, which we explain in that same article.
Walk-forward analysis, also called walk-forward optimization, tries to measure it with a simple rule: the parameters are chosen on one stretch and judged on a later one, which played no part in the choice.
- You optimize on one stretch of history. That’s the in-sample data.
- You test on the next stretch with the chosen parameters, without touching them. That’s the out-of-sample data.
- You move everything forward and repeat, until you reach the end of the history.
- You put only the test stretches together. That set is the walk-forward result.
Robert Pardo introduced the method to traders in the early 1990s, in the first edition of his book Design, Testing, and Optimization of Trading Systems, and expanded it in the second edition, from 2008, which gives it a chapter of its own. According to that book, walk-forward analysis measures performance only on out-of-sample trades, that is, on data other than the data used to optimize. It mimics someone who re-optimizes their strategy every so often and trades with the latest choice.
Backtest, out-of-sample test, walk-forward and forward test: the differences
These are four tests that often get mixed up:
| Test | What it does | What’s missing |
|---|---|---|
| Optimized backtest | Chooses the parameters on the whole history and measures them right there. | It says nothing about new data. |
| A single out-of-sample test | Splits the history in two: optimizes on the first part and tests on the second. | It depends on a single stretch, which may have been kind or harsh. |
| Walk-forward | Repeats that split several times, moving the window forward, and puts the test stretches together. | It’s still a simulation on the past. |
| Forward test on demo | Leaves the robot trading at today’s prices, with no real money. | It takes weeks or months and only covers the market of that moment. |
Watch the words. “Forward test” is used for two things: the setting in the MT5 tester, which works on historical data, and leaving a robot on a demo account (how to test a robot on demo, step by step). And “walk-forward testing” is sometimes used for the second one too. In this article, walk-forward always means the test with windows on historical data.
A worked example: rolling vs anchored walk-forward
A made-up example, which isn’t that of any particular strategy: you have history from 2019 to 2025, you optimize on two years, test on the following year and move forward one year at a time. That gives five windows:
Each row is a window. “opt”: the years used to optimize (in-sample). “test”: the year tested without touching anything (out-of-sample). The last row is what gets evaluated.
In window 1 you optimize on 2019 and 2020, and the chosen parameters trade 2021; in window 2, on 2020 and 2021, and they trade 2022; and so on until 2025. At the end there are five out-of-sample years in a row, and in none of them were the parameters chosen with that year’s own data. The first two years go untested: that’s the price of getting started.
That’s the rolling version: the optimization window is always the same length and drops the oldest data as it goes. In the anchored version, the start stays fixed and the window grows:
| Tested on | Rolling | Anchored |
|---|---|---|
| 2021 | 2019–2020 | 2019–2020 |
| 2022 | 2020–2021 | 2019–2021 |
| 2023 | 2021–2022 | 2019–2022 |
| 2024 | 2022–2023 | 2019–2023 |
| 2025 | 2023–2024 | 2019–2024 |
Neither is better as a rule. The rolling version adapts sooner to a changing market, but each window has fewer trades. The anchored one uses more data, but drags along an ever older market. The size of the windows isn’t a given either: Pardo himself lists, among the aims of the analysis, deciding how long the optimization window is and how often to re-optimize.
What is walk-forward efficiency (WFE)?
Walk-forward efficiency (WFE), a term from Pardo’s book, compares what the strategy made out-of-sample with what it made in-sample. Because the stretches aren’t the same length, the two yearly rates are compared. With made-up figures: if a strategy made an average of $2,000 a year on the optimization stretches and $1,100 a year on the test stretches, its efficiency is 1,100 / 2,000 = 55%.
As a rule of thumb, the documentation of one platform that calculates it treats 50% or more as good. That’s a convention, not a proven threshold, and it has drawbacks:
- It’s a ratio. If little was made in-sample, you get a huge percentage that means nothing. And it doesn’t tell you how far the account fell along the way.
- It depends on what you measure (profit or another criterion) and on how you turn it into a yearly figure.
- More than 100% isn’t “better”. It may just be that the test years were kinder than the optimization years.
- With few trades per stretch, it’s noise.
MetaTrader 5 doesn’t calculate this figure: if you want it, you have to work it out by hand from the results of each stretch.
How to do walk-forward analysis in MT5: the Forward setting
In the Strategy Tester (View → Strategy Tester, or Ctrl+R; how to backtest in MetaTrader 5, step by step), the Settings tab has the Forward field. Its options:
- “No”: it isn’t used.
- “1/2”, “1/3” and “1/4”: holds back half, a third or a quarter of the date range.
- “Custom”: you enter the date on which the forward period starts.
The part held back is always the last one. MetaQuotes calls the first part the back testing period and the second, the forward period. What happens next depends on whether you optimize:
- With optimization on (how optimization works in the tester), it searches for the parameters in the first part and runs the best combinations through the second. Not all of them go through: according to its help, only the best ones, the top 10% with the slow complete algorithm and at least the top 25% with the genetic one, and never fewer than 256 passes if there are that many.
- Without optimization, it tests the robot with the parameters it has on both stretches and shows the second on the “Forward” tab, next to “Backtest”. On the chart, a vertical line marks where it starts.
After an optimization, the results are in “Optimization Results” (right-click to switch between “Back Test Results” and “Forward Test Results”) and on the forward tabs next to it: in the English terminal we checked they’re called “Forward Results” and “Forward Graph”, and the label can change with the version. The result figure for each combination is that of the Criterion you chose (“Balance max”, “Sharpe Ratio max”…), calculated on each stretch. Double-click a row and the tester reruns that combination, so you can read each stretch like any other report: profit, profit factor, drawdown and number of trades (how to read the Strategy Tester report).
The MetaQuotes help says that the better the results of the two stretches coincide, the more likely it is that the robot will show good results in live trading. A match is a sign, not a guarantee.
The Forward setting in MT5 is a single pass: one optimization stretch and one test stretch. It doesn’t move the window forward, doesn’t repeat the optimization, doesn’t put the stretches together and doesn’t calculate the efficiency. An article published on MQL5, the MetaQuotes community site, puts it this way: the tester doesn’t let you launch a walk-forward “at the touch of a button”.
Chaining the windows by hand
With the example above, the manual way would be this:
- Decide the rules before you start and write them down: how long the windows are, which criterion you optimize by and which combination you’ll keep (for example, the top one by that criterion on the optimization stretch).
- Window 1. Under Date, choose “Custom period” and enter January 1, 2019 to January 1, 2022: according to the MetaQuotes help, the end date isn’t included, and the test ends on the last tick of the previous day. Under Forward, choose “Custom” and enter January 1, 2021.
- Optimize and note what the combination your rule picked did in the forward period. Not the one with the best forward result.
- Move the three dates forward one year and repeat, up to window 5 (January 1, 2023 to January 1, 2026, with the forward period starting on January 1, 2025).
- Put the five forward stretches together: profit, trades and drawdowns for each one, in order.
Use the same modelling, the same deposit and the same costs in every window (which modelling mode to use). It’s slow work, which is why some people automate it with separate programs or with their own code, like the code in the MQL5 article mentioned above, which requires programming.
How to read a walk-forward test, and where its limits are
There’s no official pass mark. This is what people usually look at:
- The test stretches, put together, make money, and the result doesn’t come from a single stretch or a single trade.
- Out-of-sample does worse than in-sample, but doesn’t collapse. Doing worse is normal: in-sample, the best was picked.
- There are enough trades in each stretch for the figures to mean something.
And this is what raises suspicion: it shines in-sample and loses or goes flat out-of-sample, nearly all the profit comes from one stretch, or the result changes a lot when you shift the dates a little. Even when it looks good, a walk-forward has limits:
- Few trades. Splitting the history leaves each stretch with fewer. A year with twenty trades can turn out well or badly by chance.
- Regime changes. The market in the test stretch may not look like the one in the optimization stretch: gold, for example, moves far more today than in 2020 (how much gold’s ATR has changed). And the next change isn’t in any stretch.
- Re-optimizing too often. With short windows, the parameters chase the noise of the last few months. With long ones, they go stale. There’s no rule: it’s a balance.
- Peeking. If you repeat the walk-forward, changing windows, criterion or rules until it looks good, or pick the combination by its result in the forward period, that stretch has become in-sample, even if you keep calling it out-of-sample. MT5 shows the forward results of many combinations at once: keeping the one that did best there is exactly that. An academic paper on backtest overfitting makes the same point: what matters is how many variants were tried before choosing, and holding back a stretch doesn’t account for that.
- Costs and spread. Each stretch inherits the backtest’s assumptions. With a fixed spread or no commissions, the walk-forward comes out as flattered as the backtest (why a backtest with a fixed spread can mislead).
A walk-forward answers one specific question: whether the parameters chosen on the past held up on the next stretch, several times in a row. Passing it guarantees nothing about the future: it’s still a simulation. What it doesn’t cover is today’s market: only a test on demo and, after that, the results of a live account that can be checked will show you that (how to read a verified live account).
What AUREUM’s home page says about its validation
AUREUM is an Expert Advisor, software that runs two gold strategies (XAU/USD) in your own MetaTrader 5 account. This article doesn’t describe its strategy. Its home page explains that its two strategies “were built on data up to 2016 and checked against the ten years that followed, which they never saw while being created”, and that they passed Monte Carlo analysis. That is an out-of-sample check, not a walk-forward with re-optimisation like the one this article describes.
Its published backtest, a simulation on XAU/USD on H1 from 2024 to 2026, has 345 trades and a maximum drawdown of 22.35%. An account running AUREUM can also lose money.
Walk-forward analysis FAQ
What is walk-forward analysis in trading?
It’s a way of testing a strategy on data it hasn’t seen. You optimize on one stretch of history (in-sample), test the chosen parameters untouched on the next stretch (out-of-sample), move the window forward and repeat until the end. The result that counts is the out-of-sample stretches put together. It’s also called walk-forward optimization or walk-forward testing. Robert Pardo introduced the method to traders in a book first published in the early 1990s.
What is the difference between a backtest and walk-forward analysis?
A backtest applies the strategy to historical data and measures the result; if you optimized the parameters on that same data first, the result is flattered. Walk-forward analysis is a chain of backtests in which each stretch is tested with parameters chosen only from earlier data. Both are simulations on the past.
How do you do walk-forward analysis in MetaTrader 5?
MetaTrader 5 has no complete walk-forward. Its Strategy Tester has the Forward setting, which does one pass: it optimizes on the first part of the date range and tests the best combinations on the last part. For a walk-forward you repeat it by hand: set the dates with Custom period and Custom, optimize, note the result of the forward stretch, move the dates forward and start again. At the end you put the forward stretches together.
What is the Forward period (forward test) in the MT5 Strategy Tester?
It’s the last part of the date range, which the tester sets aside to check the parameters on data it didn’t use to optimize. You choose it in the Forward field of the Settings tab: No, 1/2, 1/3, 1/4 or Custom, which lets you enter the start date. According to the MetaQuotes help, not every combination goes through to the forward period, only the best ones: the top 10% with the slow complete algorithm and at least the top 25% with the genetic one.
What are in-sample and out-of-sample data?
In-sample data is the data used to choose a strategy’s parameters. Out-of-sample data played no part in that choice and is used only to check it. A stretch stops being out-of-sample the moment you use it to decide something: for example, if you keep the combination that did best on it.
Does passing a walk-forward test guarantee the strategy will work?
No. It’s a simulation on the past, with the same assumptions about spread, commissions and execution as the backtest, and the market can change after the last stretch. And if you repeat it many times, changing windows or rules until it looks good, it stops measuring what it’s meant to. Past or simulated results do not guarantee future results.
How often should you re-optimize?
There’s no rule. Re-optimizing often adapts the parameters sooner to a changing market, but each window has fewer trades and it’s easier to fit noise. Doing it rarely gives windows with more data, but the parameters can go stale. You decide the frequency before you start, and it’s part of the test: a walk-forward with one-year test stretches describes a strategy that is re-optimized every year.
The menus and options in this article were checked in November 2026 with MetaTrader 5 for desktop and with the MetaQuotes documentation; they can change with the platform version. The windows and figures in the examples are made up and only serve to explain the method. A walk-forward is a simulation on past data: passing it doesn’t guarantee what a strategy will do afterwards. Leveraged gold trading, which on MetaTrader 5 brokers is usually done with CFDs, carries a high level of risk and you can lose some or all of your capital: most retail CFD accounts lose money (how many traders lose money). The AUREUM figures we quote come from a simulation (backtest), not from a live account. Past or simulated results do not guarantee future results. This content is educational and is not financial or investment advice.
AUREUM: automated rules on gold, with its backtest published
Software that runs two strategies on XAU/USD in your own MetaTrader 5 account, where every trade opens with its loss and profit limits already calculated. Its 2024–2026 backtest, with both strategies together, is published with its drawdowns: a maximum drawdown of 22.35% across 345 trades. It’s a simulation, not a live account, and trading leveraged CFDs can lose you money.
See the full report →