Loading…

Breach Post Mortem Recorder

The moment something goes wrong on an account is exactly the moment nobody has time to screenshot everything. This EA does that job automatically: it watches a short list of user-configured breach conditions on every tick, and the instant one is met it freezes a complete picture into one text file - account balance, equity, margin and margin level; every currently open order with its open time, open price, current price and floating result; and the most recent closed trades immediately before the breach for context - so the exact situation can be reviewed afterward instead of reconstructed from memory or a scrolled-past Experts log. Five trigger types are supported and each can be switched on or off independently: today's realised loss exceeding a percent of the day's estimated start balance, equity drawdown from its recorded peak, open aggregate lots across matching orders, margin level falling below a threshold, and an external flag. The external flag lets a second EA that detects its own kind of breach - one this program has no way to know about on its own - trigger a post-mortem here anyway, by setting a shared terminal global variable to a non-zero value. A cooldown between reports stops one ongoing breach (for example, equity sitting continuously below the drawdown limit) from writing a fresh file every single tick. Notes and limitations - Report-only. It never sends, closes or modifies an order - it only records what it observes at the moment a configured condition is met. - The daily-loss figure is an estimate built from closed trade history, not a genuine tick-by-tick equity curve; a day with a large floating drawdown that closed flat will not be flagged even if it briefly breached the limit intraday. - The external-trigger mechanism relies on the other program actually setting the shared global variable - it does nothing on its own if that companion EA is not running or misconfigured. - Files are written inside the MQL4 sandbox (MQL4\Files\ (or MQL5\Files\ on the native MQL5 build)) as this platform has no permission to write anywhere else; move or back them up manually if needed.

Expert advisor · MT5 · v1.0 · Free

About Breach Post Mortem Recorder

Breach Post Mortem Recorder is a script for MetaTrader 5. It can alert you with a pop-up, sound, email or push message. It has 14 settings, such as Trigger on daily loss, Max daily loss percent and Trigger on drawdown. MQL source code included.

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

Settings

SettingDefaultWhat it does
Trigger on daily losstrueTrigger when today's realised net loss exceeds the limit below
Max daily loss percent5.0Percent of today's estimated start balance
Trigger on drawdowntrueTrigger when equity drawdown from its peak exceeds the limit below
Max overall drawdown percent10.0Percent
Trigger on aggregate lotsfalseTrigger when open aggregate lots exceed the limit below
Max aggregate lots5.0
Trigger on margin leveltrueTrigger when margin level falls below the limit below
Min margin level percent150.0
Trigger on external flagtrueAlso trigger when another EA sets the global variable below to a non-zero value
External trigger global varBreachPostMortem_ExternalTrigger
Magic filter-1Magic number filter for the order timeline and history section (-1 = every magic number)
History lookback trades10Closed trades to include for context, most recent first
Min seconds between reports300Cooldown so one ongoing breach does not write a file every tick
Timer interval sec15

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: Alerts · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria