Loading…

Seed Dispersion Test Driver

Every Strategy Tester pass runs with exactly one pseudo-random seed, so a single backtest of a strategy with any randomness in it (or, more importantly, one that merely LOOKS deterministic but is quietly sensitive to the exact sequence of trades and fills) shows exactly one point out of a whole distribution of possible outcomes. This EA makes that visible on purpose: its entry logic is explicitly random - each new bar has a fixed percentage chance of opening a trade in a random direction, reseeded from InpSeed in OnInit() via MathSrand() so the SAME seed always reproduces the SAME sequence of trades. Run alone, one pass just shows one random outcome. Run as an OPTIMISATION with InpSeed stepped across a range (e.g. 1 to 200, step 1) with every other input fixed, each pass reseeds independently, trades its own reproducible sequence, and OnTester() appends that pass's net profit, trade count, profit factor and drawdown to a shared CSV - then reads the accumulated file back and prints the running mean, standard deviation, coefficient of variation and range across every seed processed so far. After the whole optimisation completes, that CSV holds the full outcome distribution for a "strategy" with literally zero edge, which is a useful calibration reference: any real strategy under test should be compared not just to zero, but to how WIDE the zero-edge distribution's spread already is at similar trade counts. Notes and limitations - MathRand() returns a value in 0..32767; the entry-probability roll and direction choice are both derived from it, which is adequate for this purpose (illustrating dispersion, not cryptographic quality) but is not a high-quality random source. - The results file accumulates across every pass of an optimisation that shares the same InpResultsFile name; delete or rename it before a fresh sweep if a clean distribution (not mixed with a previous run's rows) is wanted. - The dispersion figures printed mid-run only cover the seeds processed by that Tester thread SO FAR when multiple optimisation threads run in parallel, results from other threads may not yet be in the file - the FINAL pass to write is the first point the file is guaranteed complete, and even then only if all threads share one results file path. - This EA carries no trading edge whatsoever by design; it must never be run on a live or funded account as a strategy.

Expert advisor · MT4 · v1.0 · Free

About Seed Dispersion Test Driver

Seed Dispersion Test Driver is an expert advisor (trading robot) for MetaTrader 4 based on ATR. It has 10 settings, such as Seed, Entry probability pct and Fixed lots. MQL source code included.

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

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

Settings

SettingDefaultWhat it does
Seed1Pseudo-random seed for this pass - set this as the OPTIMISED input (e.g. 1 to 200, step 1)
Entry probability pct5.0Chance per new bar of taking a randomly-directed trade
Fixed lots0.10Fixed lot size
Atr period14ATR period for the protective stop
Stop atr multiple2.0Stop distance, in ATR multiples
Magic number41000Magic number for orders opened by this EA
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds
Results fileSeedDispersionTestDriver_Results.csvAccumulated per-seed results, 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 → Experts.
  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 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: ATR · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria