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
| Setting | Default | What it does |
|---|---|---|
| Seed | 1 | Pseudo-random seed for this pass - set this as the OPTIMISED input (e.g. 1 to 200, step 1) |
| Entry probability pct | 5.0 | Chance per new bar of taking a randomly-directed trade |
| Fixed lots | 0.10 | Fixed lot size |
| Atr period | 14 | ATR period for the protective stop |
| Stop atr multiple | 2.0 | Stop distance, in ATR multiples |
| Magic number | 41000 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
| Results file | SeedDispersionTestDriver_Results.csv | Accumulated per-seed results, under MQL4\Files\ |
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 → Experts.
- 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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: ATR · MT4 Expert Advisor · MQL4 Source Code