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
| Setting | Default | What it does |
|---|---|---|
| Trigger on daily loss | true | Trigger when today's realised net loss exceeds the limit below |
| Max daily loss percent | 5.0 | Percent of today's estimated start balance |
| Trigger on drawdown | true | Trigger when equity drawdown from its peak exceeds the limit below |
| Max overall drawdown percent | 10.0 | Percent |
| Trigger on aggregate lots | false | Trigger when open aggregate lots exceed the limit below |
| Max aggregate lots | 5.0 | |
| Trigger on margin level | true | Trigger when margin level falls below the limit below |
| Min margin level percent | 150.0 | |
| Trigger on external flag | true | Also trigger when another EA sets the global variable below to a non-zero value |
| External trigger global var | BreachPostMortem_ExternalTrigger | |
| Magic filter | -1 | Magic number filter for the order timeline and history section (-1 = every magic number) |
| History lookback trades | 10 | Closed trades to include for context, most recent first |
| Min seconds between reports | 300 | Cooldown so one ongoing breach does not write a file every tick |
| Timer interval sec | 15 |
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: Alerts · MT5 Expert Advisor · MQL5 Source Code