Signal Stream Replay Harness
Testing "what if a filter had been applied to this signal source" is usually done by rewriting a whole strategy EA and rerunning it, which mixes the filter's effect together with everything else the strategy does. This harness isolates just the filter question: feed it a plain CSV of recorded signal timestamps and directions - produced by anything, a real strategy's own log, a manual list, an exported alert history - and it replays each one against the chart's own historical Open prices as a purely virtual trade, entirely in memory, with no OrderSend call anywhere in the file. Two handling rules are built in, selected by an input so the SAME signal file can be scored twice for a direct comparison. RAW takes every signal exactly as logged. FILTERED adds two conditions common to real signal-quality filters: the signal's direction must agree with a moving average's recent slope, and a same-direction signal within a cooldown window of the last one taken is skipped rather than compounding into the same move. Every signal's outcome - taken, skipped, and why, entry/exit and points gained - is appended to a results CSV as it happens, so the two runs' files can be diffed afterwards to see exactly which signals the filter removed and what they would have been worth. Notes and limitations - No real orders are ever placed; "trades" are computed purely from Open[] prices at the signal's bar and at exit, so spread, slippage and commission are not represented. This is a signal-quality comparison tool, not a P&L forecast. - A signal timestamp landing exactly on the boundary between two bars is attributed to the bar that CLOSES it (i.e. it is processed once Time[1] reaches or passes the signal's time), matching how the signal would actually have been actionable on the next bar's open. - The signal file is loaded once in OnInit() and sorted defensively by timestamp; a very large file (tens of thousands of rows) will use a correspondingly larger amount of memory, since the whole stream is held in arrays for the run. - Only one virtual position is tracked at a time; an opposite signal closes the current one and immediately opens the new direction rather than netting or stacking.
Expert advisor · MT4 · v1.0 · Free
About Signal Stream Replay Harness
Signal Stream Replay Harness is a script for MetaTrader 4 based on Moving Average. It can alert you with a pop-up, sound, email or push message. It has 6 settings, such as Signal file, Output file and Variant. MQL source code included.
Files in the download: SignalStreamReplayHarness.ex4, SignalStreamReplayHarness.mq4, SignalStreamReplayHarness.txt.
Settings
| Setting | Default | What it does |
|---|---|---|
| Signal file | SignalStreamReplayHarness_Signals.csv | Recorded signal file, under MQL4\Files\ |
| Output file | SignalStreamReplayHarness_Results.csv | Per-signal outcome log written on this run |
| Variant | VARIANT_RAW | Which handling rule this run scores |
| Hold bars | 20 | Virtual holding period in bars if no closing signal arrives first |
| Trend ma period | 50 | EMA period used by the FILTERED variant's trend-alignment check |
| Cooldown bars | 5 | FILTERED variant ignores a same-direction signal within this many bars of the last accepted one |
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: Buy/Sell Arrows · Trend · Alerts · Moving Average · MT4 Expert Advisor · MQL4 Source Code