Walk Forward Conductor
An MQL4 program cannot launch the Strategy Tester, set its From/To dates, or read back what the operator configured on the Settings tab - none of that is exposed to running code on either platform. Any "walk-forward automation" claiming otherwise is not being honest about what it actually does. What this EA does instead is coordinate the parts that ARE reachable from inside a running program: it builds the rolling window plan (a standard anchored-step walk-forward layout - each window's out-of-sample segment becomes the roll distance to the next window's start), writes it to a CSV file, and on attachment prints the exact date range the operator needs to type into the Tester's Settings tab for the window and phase selected by this run's inputs. It then leans on the one genuinely reliable automatic hook available - OnTester(), which the Tester calls at the end of every completed pass regardless of platform - to read that pass's own statistics and append one row to a shared results file, tagged with the window and phase it belonged to. The workflow is therefore semi-manual by necessity: generate the plan once, then for each window run the in-sample segment as one Tester pass (optimising parameters), copy the winning parameters into a second pass over the out-of-sample segment, and let this EA log both. After all windows are done, the results CSV holds a clean in-sample vs out-of-sample comparison per window - the walk-forward analysis itself - without the operator having to hand-track dates and results in a spreadsheet. Notes and limitations - This EA does not trade and does not implement any strategy itself. It is meant to run either alongside the strategy under test (two EAs cannot share one chart in the Tester, so in practice this means folding OnInit()'s date-printing and OnTester()'s result-logging into your own strategy EA's source) or as a placeholder pass used only to confirm the plan/date bookkeeping before wiring it into the real strategy - the .txt's HOW TO USE section describes the placeholder-pass workflow for clarity, but production use means merging this file's OnTester() body into the strategy being tested. - There is no way to programmatically verify that the Tester's actual configured From/To dates match InpCurrentWindowIndex/InpCurrentPhase - OnInit() only compares against the chart history that happened to load and warns on an obvious mismatch, which catches gross errors (wrong decade, wrong window entirely) but not a close one. - AddMonths() clamps day-of-month at each month's own length (Jan 31 rolls to Feb 28/29, not into March) - a deliberate choice so window boundaries stay predictable, not a bug. - Every value in the results CSV comes straight from TesterStatistics() for that single pass; this EA does not itself judge whether a parameter set "passed" walk-forward validation - that comparison is left to the operator reading the CSV.
Expert advisor · MT4 · v1.0 · Free
About Walk Forward Conductor
Walk Forward Conductor is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 9 settings, such as Plan file, Results file and Regenerate plan. MQL source code included.
Files in the download: WalkForwardConductor.ex4, WalkForwardConductor.mq4, WalkForwardConductor.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Plan file | WalkForwardConductor_Plan.csv | Plan file name, under MQL4\Files\ |
| Results file | WalkForwardConductor_Results.csv | Results file name, under MQL4\Files\ |
| Regenerate plan | false | Force-rebuild the plan file from the inputs below, even if it exists |
| First window start | 2018.01.01 | Calendar start of window 1, format YYYY.MM.DD |
| In sample months | 6 | Length of each in-sample segment, in months |
| Out sample months | 2 | Length of each out-of-sample segment, in months (also the roll step) |
| Window count | 10 | How many rolling windows to generate |
| Current window index | 1 | Which window THIS Tester run corresponds to (1-based) |
| Current phase | PHASE_INSAMPLE | Which phase THIS Tester run corresponds to |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: Alerts · MT4 Expert Advisor · MQL4 Source Code