Discussing the article: "Dead-Man's Switch for MetaTrader 5: An EA Heartbeat That Reports Health, and a Guardian That Acts When It Goes Silent"

Check out the new article: Dead-Man's Switch for MetaTrader 5: An EA Heartbeat That Reports Health, and a Guardian That Acts When It Goes Silent.

This article builds a dead man's switch for EAs: a host emits a timer-driven heartbeat with real health flags (connection, trading permissions, tick age, margin) to an external relay with its own clock. A guardian EA polls that relay and, once silence is confirmed, can alert, move stops to breakeven, or flatten positions by magic number.

Every EA I've shipped eventually asks the same question at 3 a.m.: is it actually still running, or did it quietly stop three hours ago while still looking green in the terminal? A crashed EA is loud - you get a popup, a red cross on the chart. A silently stuck EA is not. AutoTrading can get toggled off by someone else on a shared VPS, a broker can freeze quotes without disconnecting the terminal, a timer handler can hang on a blocking call you didn't think was blocking, and the chart will sit there looking perfectly normal while nothing is happening behind it.

This article builds a dead man's switch for that exact failure mode. One EA (the host) emits a small, information-dense "health beat" every few seconds to a relay process that lives outside the terminal. A second EA (the guardian) polls that relay and runs its own state machine, independent of whatever is wrong with the host. If the beats stop for long enough, the guardian confirms it, alerts, and - if you want it to - acts: moves stops to breakeven or flattens the positions tied to a magic number.

I ran the whole thing on a real MetaQuotes-Demo account, injected two different kinds of fault on purpose, and recorded what actually happened, including one thing that didn't go the way I expected on the first pass. That part stays in.

Author: Olamide Daniel Adebayo