Loading…

Walk Forward Helper EA

Walk-forward validation is normally a manual, repetitive exercise: slice the history into date ranges by hand, re-run the Strategy Tester over and over, and compare the results by eye. This EA does the slicing itself. Starting from one anchor date and two configurable lengths, it works out which window any given moment in the backtest falls into, and whether that window is the in-sample half of its cycle - where trading is deliberately switched off, on the assumption that this is where parameters would already have been chosen by an optimisation pass - or the out-of-sample half, where the strategy is actually allowed to trade. Every open position is forced flat the instant a window boundary is crossed, so no trade ever straddles the line between in-sample and out-of-sample, and each finished window's trade count and net profit are pulled fresh from account history at that moment - correct whether a trade closed by this EA's own logic or by hitting its stop loss - and written as one CSV row. Run once over a full multi-year history, the result is a window-by-window table showing whether a strategy actually holds up out-of-sample time after time, or only looked good in the one continuous run everyone normally tests. The EA ships with a plain fast/slow EMA crossover as a placeholder signal so the framework is runnable immediately, clearly marked in the source as something to replace with real strategy logic. The windowing, flattening and CSV reporting around it do not need to change no matter what the real signal ends up being. Notes and limitations - This is a framework for the windowing and reporting mechanics, not a ready-to-trade strategy. The shipped EMA crossover is a placeholder and should not be judged, or traded, as a finished system. - "In-sample" here means "no trading happens" - this EA does not perform its own parameter optimisation during the in-sample segment. It assumes that step was, or will be, done separately in the Strategy Tester's own optimiser using only that segment's date range. - Forcing every position flat at a window boundary can cut a genuinely good trade short if the boundary happens to land mid-trade; this is the deliberate cost of guaranteeing no trade straddles the in-sample line. - On MQL5 netting accounts, a foreign-magic position already on the symbol blocks every new placeholder entry rather than merging into it - see above.

Expert advisor · MT5 · v1.0 · Free

About Walk Forward Helper EA

Walk Forward Helper EA is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average. It has 12 settings, such as Anchor date, In sample days and Out sample days. MQL source code included.

Files in the download: WalkForwardHelper.ex5, WalkForwardHelper.mq5, WalkForwardHelper.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Anchor date2024.01.01First in-sample window starts here (server time, yyyy.mm.dd)
In sample days180Length of each in-sample segment, in days - no trading happens here
Out sample days60Length of each out-of-sample segment, in days - the placeholder signal may trade here
Fast ma period10Placeholder signal: fast EMA period
Slow ma period30Placeholder signal: slow EMA period
Fixed lots0.10Fixed lot size for the placeholder signal's trades
Stop loss pips50Protective stop for the placeholder signal's trades, in pips (0 = none)
Magic number20260907Magic number for orders this framework opens
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds
Export window logtrueAppend one CSV row per finished window to the sandbox Files folder

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Moving Average · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria