Synthetic Series Generator
A backtest only ever tests one realised sample of history. A strategy that looks robust on five years of EURUSD may simply have been lucky about the particular sequence of moves that occurred, and there is no way to know from that one sample alone. Testing against additional plausible price paths - not the one that happened, but ones with statistically similar behaviour - is how that question actually gets answered. This EA builds those additional paths two ways. Random walk mode measures the base symbol's own historical volatility (and, optionally, its mean return) and generates a fresh Gaussian random walk with the same statistical character, producing a plausible but entirely synthetic price series. Block bootstrap mode instead resamples the base symbol's own real historical returns in contiguous blocks, with replacement, and chains them into a new series. Resampling in blocks rather than one return at a time matters: shuffling every return independently destroys volatility clustering - the real tendency of calm periods to stay calm and turbulent ones to stay turbulent - because it severs each return from its neighbours. Keeping a block's returns in their original order preserves that clustering across the block, which is what makes the bootstrap a meaningfully different, more realistic test than a naive shuffle. Each generated bar is built from several small forced sub-steps that sum to exactly the bar's intended close-to-close return, giving every bar a plausible open/high/low around its close rather than a flat body with no wick. The finished series is written as a plain CSV in the format MetaTrader's History Center import expects, ready to become an offline chart under a synthetic symbol name of your choosing. Notes and limitations - This is a data generator, not a trading strategy - it never places an order. - Timestamps advance continuously through weekends and holidays rather than reproducing a real market's session gaps; the price path itself is unaffected, only the calendar layout of the imported chart. - The Volume column is a rough proxy derived from each bar's simulated range, not a meaningful tick count - synthetic bars have no real tick data behind them. - Block bootstrap needs at least twice InpBootstrapBlockSize historical returns available on the base symbol/timeframe; load more history in the terminal first if it reports too little. - Every open/high/low is simulated from the same volatility model used for the close-to-close return, not sourced from any real intrabar data, even in bootstrap mode.
Expert advisor · MT5 · v1.0 · Free
About Synthetic Series Generator
Synthetic Series Generator is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 10 settings, such as Mode, Base symbol and Timeframe. MQL source code included.
Files in the download: SyntheticSeriesGenerator.ex5, SyntheticSeriesGenerator.mq5, SyntheticSeriesGenerator.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Mode | GEN_RANDOM_WALK | Generation method |
| Base symbol | Source symbol for volatility/returns (blank = chart symbol) | |
| Timeframe | PERIOD_H1 | Bar period of both the source read and the output |
| Bars to generate | 5000 | Number of synthetic bars to produce |
| Starting price | 0.0 | 0 = use the base symbol's current Bid |
| Bootstrap block size | 20 | Contiguous block length, bars (GEN_BLOCK_BOOTSTRAP only) |
| Include historical drift | true | Use the source's mean return as drift (GEN_RANDOM_WALK only) |
| Random seed | 0 | 0 = seed from the clock, otherwise reproducible |
| Output file name | Blank = auto-named from symbol and timeframe | |
| Use common folder | false | Write to the shared Terminal\Common\Files folder |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
- Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
- Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: EURUSD · Alerts · MT5 Expert Advisor · MQL5 Source Code