Deadman Switch Guardian
An automated strategy is only as safe as the person who is supposed to be watching it. If that person is unreachable - a hospital stay, a lost laptop, a trip with no signal - a strategy that depends on someone being there to react can keep running unattended for far longer than anyone intended. This is a check-in clock, not a trading system. Click the on-chart button, or - for check-ins from outside the terminal entirely - touch a file in the sandbox from a phone shortcut, a scheduled task, or any script that can write a file, and the clock resets. If the configured interval passes with no check-in from either channel, every open position on the account is closed and every pending order is deleted, and the owner is alerted that the switch tripped. The last check-in time is stored in a terminal GlobalVariable rather than kept only in memory, so restarting the EA - or the whole terminal - does not itself count as a check-in and quietly reset the clock. A genuine silence is still a genuine silence across a crash and relaunch. Notes and limitations - Once tripped, it stays tripped (recorded in a GlobalVariable) until a fresh check-in arrives - it does not repeatedly re-flatten an account that is already flat. - A fresh attach seeds the check-in clock to the current time rather than to whatever the terminal's last-known state was, so installing it for the first time does not immediately trigger. - Flattening requires AutoTrading to be enabled; if it is off when the switch trips, the EA alerts loudly but cannot act, and says so. - The file check-in channel only reads the file's modify timestamp - it never reads or validates the file's contents, so any tool capable of writing to that path can check in.
Expert advisor · MT5 · v1.0 · Free
About Deadman Switch Guardian
Deadman Switch Guardian is an expert advisor (trading robot) for MetaTrader 5. It has 9 settings, such as Check in interval hours, Warn before minutes and Use file check in. MQL source code included.
Files in the download: DeadmanSwitchGuardian.ex5, DeadmanSwitchGuardian.mq5, DeadmanSwitchGuardian.txt.
Trading robots can lose money. Check every setting and test on a demo account before using real funds.
Settings
| Setting | Default | What it does |
|---|---|---|
| Check in interval hours | 24 | Maximum silence allowed before the account is flattened |
| Warn before minutes | 60 | Alert this many minutes before the switch would trip |
| Use file check in | true | Also accept a check-in via a file touched in MQL5\Files |
| Check in file name | DeadmanSwitchGuardian_checkin.txt | File watched for a check-in (sandbox path) |
| Use button check in | true | Show the on-chart "I'm here" button |
| Dry run | false | true = alert only when tripped, never actually flattens |
| Timer interval sec | 30 | How often the clock and the file are checked |
| Max retries | 5 | Attempts per order action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
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 → Experts.
- 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 expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Buy/Sell Arrows · Pending Orders · MT5 Expert Advisor · MQL5 Source Code