Loading…

Spread Attack Replay Demonstrator

Traders using very tight stops are often warned that a spread-widening event - around news, at rollover, or during thin liquidity - can take out a stop with no real price move at all, purely because the spread itself grew wider than the stop distance. That warning is usually qualitative. This tool measures it: no standard "recorded spread-event file" format exists to download, so it is genuinely self-contained - RECORD mode watches this account's own live spread and logs each distinct widening episode (start time, duration, peak spread) to a CSV file the moment the spread first clears a configurable threshold and again the moment it drops back down, rather than logging every tick of a sustained wide-spread period as a separate row. REPLAY mode reads that same file back and checks a fixed ladder of common "tight" stop distances (3, 5, 8, 10, 15, 20 and 30 pips) against every recorded episode's peak spread, reporting how many episodes alone - with no price movement required - would have exceeded each stop distance. The result is a concrete, symbol-specific answer built from this account's own recorded spread behaviour, not a generic claim about spread risk in the abstract. Notes and limitations The recorded history is only as good as the period it was recorded over - a quiet session with no news releases will log few or no episodes, and the replay comparison needs a genuine sample to mean anything. This tool measures spread widening only; it does not model actual stop-order execution mechanics (a real stop-loss is normally triggered against the Bid for a long or Ask for a short at the moment the spread widens, and slippage on top of that is a separate, unrecorded effect). Results are specific to the symbol and broker this account was connected to while recording - they do not generalise to a different symbol or broker without recording that combination separately.

Expert advisor · MT5 · v1.0 · Free

About Spread Attack Replay Demonstrator

Spread Attack Replay Demonstrator is a script for MetaTrader 5. It has 4 settings, such as Mode, Widening threshold pips and Event file name. MQL source code included.

Files in the download: SpreadAttackReplay.ex5, SpreadAttackReplay.mq5, SpreadAttackReplay.txt.

Settings

SettingDefaultWhat it does
ModeMODE_RECORDTool mode
Widening threshold pips3.0Spread level (pips) that starts a recorded episode
Event file nameSpreadAttackReplay_Events.csvFile name inside MQL5\Files
Recalc seconds5Minimum seconds between REPLAY recalculations

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Scripts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 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: News Trading · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria