Loading…

Data Perturbation Robustness Harness

A single backtest result is one sample from one specific price path. A strategy whose parameters were tuned against the exact sequence of historical prices can show an excellent single backtest while having no real edge at all - it simply memorised the noise in that one path. The way to tell the difference is to ask what happens to the result under small, repeated, independent perturbations of the same data: a genuine edge survives a jitter no bigger than normal spread or a broker's tick rounding; a curve-fit result falls apart. This EA implements exactly that check for a simple embedded fast/slow EMA crossover rule. It takes the chart's own historical closes over a configurable window, adds an independent uniform random offset (up to a configurable number of points) to every bar's close on every run, reruns the rule against the jittered series, and repeats this InpNumRuns times. Only the close price is perturbed - Open/High/Low/Volume are left untouched - because the goal is testing sensitivity to close-price noise specifically, not fabricating a whole synthetic bar shape. The report is a CSV with each run's trade count and net result in points, plus the unperturbed baseline for comparison and the mean and standard deviation across all jittered runs. A wide spread relative to the baseline is the signal that the rule's apparent performance is fragile to noise this small - a result that would never survive live trading's own inherent randomness either. Notes and limitations - Report-only: this EA never calls OrderSend and never touches the account, live or demo, under any input combination. - The embedded rule is intentionally simple (a fast/slow EMA crossover) so the harness itself stays a short, auditable file; swapping in a different embedded rule means editing RunRule() directly, which is by design for a template of this kind rather than a limitation to work around. - Jitter is applied only to the close price used by the rule, not to Open/High/Low/Volume, so this measures sensitivity to close-price noise specifically, not a full synthetic-bar Monte Carlo. - The study runs once in OnInit, not continuously - it is a one-shot analysis tool, not a live monitor. - MathRand()'s roughly 15-bit range is adequate for this use (a coarse jitter magnitude, not cryptographic randomness) but should not be mistaken for a high-resolution random source.

Expert advisor · MT4 · v1.0 · Free

About Data Perturbation Robustness Harness

Data Perturbation Robustness Harness is a script for MetaTrader 4. It can alert you with a pop-up, sound, email or push message. It has 7 settings, such as Bars to test, Num runs and Jitter points. MQL source code included.

Files in the download: DataPerturbationHarness.ex4, DataPerturbationHarness.mq4, DataPerturbationHarness.txt.

Settings

SettingDefaultWhat it does
Bars to test500How many recent closed bars to include in each run
Num runs30Number of independently jittered reruns
Jitter points5.0Max absolute jitter per bar, in points (uniform, symmetric)
Fast ma period10Embedded rule: fast MA period
Slow ma period30Embedded rule: slow MA period
Random seed00 = seed from GetTickCount(); any other value reproduces the same run set
Output file nameDataPerturbationHarness_report.csvWritten under MQL4\Files\

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the script onto a chart to run it once.

Download the PDF guide

Tags: Alerts · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria