Advertisement IC Markets

Heartbeats and alerts for an EA running on a VPS

Share, develop, and backtest custom MQL4/MQL5 Expert Advisors, Python data-scraping scripts, trading bots, and automated market alert systems.
Post Reply
Fairman
Posts: 6757
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Heartbeats and alerts for an EA running on a VPS

Post by Fairman »

Heartbeats and alerts for an EA running on a VPS

If you run an EA on a VPS, the scary scenario isn't a bad trade. It's the EA silently stopping and you not noticing for hours or days. Platform crashes, the VPS restarts for updates, the connection drops, or the EA hits an error and stops trading.

A heartbeat is a simple way to catch this. The EA sends a small message at regular intervals, every fifteen minutes say, to somewhere you'll see if it stops. That could be a push notification to your phone through MT5, a message to a Telegram bot, or a line written to a file that another script checks.

The point is that silence becomes a signal. If you don't get a heartbeat for an hour, something's wrong.

I'd also send alerts on specific events: an order failing, the connection dropping, margin level getting low, or the EA hitting a daily loss limit. Not every trade, or you'll start ignoring them.

The other side is the VPS itself. Set Windows updates so they don't restart the machine during trading hours, and make sure the platform starts automatically after a restart with the EA attached.

It's a bit of setup, but it means you're not relying on luck.
It’s Fairman :geek:
Recommended broker for automated trading & scalping IC Markets
Fairman
Posts: 6757
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Heartbeats and alerts for an EA running on a VPS

Post by Fairman »

MT5's built in push notifications are the easiest starting point. You link the platform to your phone with the MetaQuotes ID, and the EA can call SendNotification. It doesn't need any external services. The downside is limited formatting and rate limits on how often you can send. For heartbeats every fifteen minutes it's fine. For anything more complex, a Telegram bot with a web request from the EA gives more flexibility. Either way, the important thing is that silence gets noticed quickly, ideally within an hour rather than the next morning.
It’s Fairman :geek:
Fairman
Posts: 6757
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Heartbeats and alerts for an EA running on a VPS

Post by Fairman »

A heartbeat should include a bit of state, not just 'I'm alive'. Equity, number of open positions and the time of the last tick received are useful. If the heartbeat arrives but the last tick time is old, the EA is running but the connection might be stale. That's a failure mode that a simple alive message wouldn't catch. A one line summary is enough, and it makes the heartbeat actually informative when you glance at it. Adding margin level is a nice touch too, since a slow drift in margin often shows up before anything breaks.
It’s Fairman :geek:
FXS Prop Desk
Posts: 1572
Joined: Wed Oct 07, 2026 9:52 am

Re: Heartbeats and alerts for an EA running on a VPS

Post by FXS Prop Desk »

A simple heartbeat sends a message to Telegram or email every hour with the EA status and the account equity. If the message stops, something is wrong.

It also helps to send an alert for specific events, like an order error or a connection loss. Combined with the heartbeat, that covers most cases where an EA could stop silently.
FXS Official Team | The Idea Lab & Strategy
Fairman
Posts: 6757
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Heartbeats and alerts for an EA running on a VPS

Post by Fairman »

Something I'd add is a check on the terminal's connection status, not just whether the EA is running. An EA can keep running and sending heartbeats while the terminal has lost its connection to the broker. Then it can't open or manage trades, but everything looks fine from the outside. Including the connection state in the heartbeat, using TerminalInfoInteger with TERMINAL_CONNECTED in MT5, catches this. If the heartbeat says connected is false for more than a minute or two, that alert needs acting on straight away. A connection alert is cheap to add and catches the failures that matter most.
It’s Fairman :geek:
Fairman
Posts: 6757
Joined: Tue Jul 21, 2026 7:11 am
Location: Abuja

Re: Heartbeats and alerts for an EA running on a VPS

Post by Fairman »

How often should a heartbeat go out? Too often, and you get used to ignoring the messages. Too rarely, and a problem can go unnoticed for hours. I've settled on a short message every hour during trading hours and an immediate alert for anything unusual, like a failed order, a disconnection or equity dropping below a set level. The hourly one is just a quick glance on the phone. The immediate ones are the ones I actually act on. Splitting them into two types keeps the important alerts from getting lost in the routine ones.
It’s Fairman :geek:
Post Reply