How do you detect when an EA silently stops trading?

Running 2 EAs on MT5 via VPS. Recently had one go quiet for about 3 days — no crash, no errors in Experts or Journal, smiley face still there, terminal connected. It just stopped taking trades.

I only found out because I manually check the accounts every few days. Could easily have been longer.

What I'm stuck on is the detection side, not the root cause. Uptime monitors only tell me the VPS is up. Telegram notifier EAs fire when something happens — but this is the opposite problem: nothing happens, and that's the failure. Everything reported the account as healthy the whole time.

So how do you catch this?

Do you track expected trade frequency and alert when it drops to zero? Heartbeats? Something in the logs I'm missing? Or does everyone just check manually like I do?

If there's a standard solution I've missed I'd rather use it than reinvent it.

123bernardino:

Running 2 EAs on MT5 via VPS. Recently had one go quiet for about 3 days — no crash, no errors in Experts or Journal, smiley face still there, terminal connected. It just stopped taking trades.

I only found out because I manually check the accounts every few days. Could easily have been longer.

What I'm stuck on is the detection side, not the root cause. Uptime monitors only tell me the VPS is up. Telegram notifier EAs fire when something happens — but this is the opposite problem: nothing happens, and that's the failure. Everything reported the account as healthy the whole time.

So how do you catch this?

Do you track expected trade frequency and alert when it drops to zero? Heartbeats? Something in the logs I'm missing? Or does everyone just check manually like I do?

If there's a standard solution I've missed I'd rather use it than reinvent it.

I don't know of a readymade solution. You can use the MQL5 standard function, SendNotification(), to send a message to Mobile MT5 on your phone/mobile device:

Forum on trading, automated trading systems and testing trading strategies

my VPS is working but does not send push notifications

douglas14, 2025.03.25 20:21


Thanks , I will do these adjustments. Just a update, the sendnotification started working when I closed the metatrader5 window. The problem I reported above was happening when I did not close the terminal AND put the computer to hibernate.


Coders usually use that standard function to send notifications of executed trades but you can get your last position time and then compare it to TimeCurrent(), for example:

Forum on trading, automated trading systems and testing trading strategies

How to get Position opening time?

Yasin Ipek, 2023.08.29 18:14

double SonPozKarHesapla()
  {
   double _karToplam=0;
   datetime _zaman=0;
   for(int i=0; i<PositionsTotal(); i++)
     {
      ulong bilet=PositionGetTicket(i);
      long sihirliIslem=PositionGetInteger(POSITION_MAGIC);
      if(PositionSelectByTicket(bilet) && sihirliIslem==1923)
        {
         double _kar=PositionGetDouble(POSITION_PROFIT);
         datetime _zamanim=(datetime)PositionGetInteger(POSITION_TIME);
         if(_zamanim>_zaman)
           {
            _karToplam=_kar;
            _zaman=_zamanim;
           }
        }
     }
   return _karToplam;
  }
The idea is to write some code in your EA that conditionally sends a notification if your last position time is greater than 2 days ago, or whichever length of time that you prefer.
Blemoragne Catayas:

Running 2 EAs on MT5 via VPS. Recently had one go quiet for about 3 days — no crash, no errors in Experts or Journal, smiley face still there, terminal connected. It just stopped taking trades.

I only found out because I manually check the accounts every few days. Could easily have been longer.

What I'm stuck on is the detection side, not the root cause. Uptime monitors only tell me the VPS is up. Telegram notifier EAs fire when something happens — but this is the opposite problem: nothing happens, and that's the failure. Everything reported the account as healthy the whole time.

So how do you catch this?

Do you track expected trade frequency and alert when it drops to zero? Heartbeats? Something in the logs I'm missing? Or does everyone just check manually like I do?

If there's a standard solution I've missed I'd rather use it than reinvent it.

You could use an heartbeat system. I can't suggest a ready made solution here, but the principle is simple : you run some code on your MT5 platform that will send a heartbeat to an external system. If something goes wrong on MT5 side, the system will not received the heartbeat and you will get a notification.

Additionally the heartbeat can be linked with some information about your system, for example "no trade for X hours", and the external system can check these information with some triggers, to also send notification, even when the heartbeat is received correctly. (Though for your use case, you could do it directly with MQL5 as suggested by Ryan).

For the simplest of idea, just calculate the average trade count that it should take in a week and then if it is way off... you have found the answer... of course their are scientific way and utilities that can help you analyze if the system is running or not. Most of the time it can be that there were actually no signal at all. 

Building on Alain's heartbeat — what makes it work for this case is the payload. Andrew's point that there may simply have been no signal is the crux, and it's why I'd put state in there rather than trade counts. Two values on a timer: when the EA last finished an evaluation, and whether the positions it thinks it holds still match the order pool by ticket. Evaluated 30 seconds ago and the tickets reconcile — healthy, traded or not. Last evaluation four hours old — broken, and you know it without waiting on a trade that was never due.

Also worth checking whether the terminal restarted during those three days. Nothing logs it and everything looks normal afterwards — chart loads, indicators fill, positions in the tab, connection green. But statics and global arrays are session-scoped and come back zeroed. Usually that shows up as overtrading (empty position array, EA thinks it holds nothing, opens on top of a live basket), though it can go the other way: if your entries are gated on state built up over previous ticks, a reset leaves the gate shut and the EA just sits there evaluating and never acting. Worth ruling out before you build monitoring for it.

Blemoragne Catayas:

Running 2 EAs on MT5 via VPS. Recently had one go quiet for about 3 days — no crash, no errors in Experts or Journal, smiley face still there, terminal connected. It just stopped taking trades.

I only found out because I manually check the accounts every few days. Could easily have been longer.

What I'm stuck on is the detection side, not the root cause. Uptime monitors only tell me the VPS is up. Telegram notifier EAs fire when something happens — but this is the opposite problem: nothing happens, and that's the failure. Everything reported the account as healthy the whole time.

So how do you catch this?

Do you track expected trade frequency and alert when it drops to zero? Heartbeats? Something in the logs I'm missing? Or does everyone just check manually like I do?

If there's a standard solution I've missed I'd rather use it than reinvent it.


This is more a redundancy approach than a monitoring, but based on such.

There are two aspects, first EA and Terminal, second Trading System.

Master/Slave setup:
Run the EA on same account twice, on independent machines. One in Master Mode, the other in slave. The slave monitors the account for executed trades. If the trade does not show up within a given grace period, something is up with the master. - Some action needs to be taken. To be determined.

Trade System Monitoring:
Run the Trading System on the same machine in two terminals on two independent accounts, different brokers, same symbol. Monitor each others taken trades, establish a statistical trade frequency, see if it is being kept by both systems. If the deviation is to large, something is up. - Some action needs to be taken. To be determined.

This is a birds eye view on a possible approach to redundancy and monitoring, and lacks quite some aspects, but should give a basic starting point.

I could imagine, some smart people here on the forum might contribute a few more aspects to take into account.

One simple approach is to make the alert fire on absence. Have the EA write a heartbeat in OnTimer, then run a tiny watchdog EA on another chart that checks the heartbeat age and the time since the last deal in history. If the heartbeat is stale, or there has been no trade for longer than your strategy normally goes quiet, it calls SendNotification() to your phone.

// in the trading EA, OnTimer()
GlobalVariableSet("HB_" + IntegerToString(MagicNumber), (double)TimeCurrent());

Note the watchdog should use TimeCurrent() too, and that only moves when ticks come in, so check it during market hours.

Navid Mirzaaghazadeh #:

One simple approach is to make the alert fire on absence. Have the EA write a heartbeat in OnTimer, then run a tiny watchdog EA on another chart that checks the heartbeat age and the time since the last deal in history. If the heartbeat is stale, or there has been no trade for longer than your strategy normally goes quiet, it calls SendNotification() to your phone.

Note the watchdog should use TimeCurrent() too, and that only moves when ticks come in, so check it during market hours.


"... check it during market hours" - That is one of the hardest tasks you can face, figuring out actual market hours.

Monitoring data stream is an aspect, I haven't covered. I would say, there are multiple approaches to do that. But it depends much more on specifics to a symbol, than it seems on the outside.

Comparing timestamps won't work reliably. It will produce lots of false positive alerts.

Using TimeCurrent might not capture, as it is updated by any received tick, and can be influenced by MarketWatch content.

It is probably better to have multiple sources of the same symbols data stream and compare their receival behavior to see if one of them/the monitored has failed.

Trying to rely on one broker connection for monitoring will not suffice the needs to accomplish actual monitoring based on redundancy.

Use a heartbeat, not trade counting. Let the EA write a timestamp to a global variable on a timer and have a watchdog EA read it. A stale timestamp means the EA stopped running, not that it found no signal.

int OnInit()
{
EventSetTimer(5);
return(INIT_INIT_SUCCEEDED);
}

void OnTimer()
{
GlobalVariableSet("hb_"+(string)AccountInfoInteger(ACCOUNT_LOGIN), TimeLocal());
}

The heartbeat approach above covers "the EA stopped running". Two other silent failures I've seen that a heartbeat won't catch, because the EA is still running happily:

1. Trading permission was switched off. The Algo Trading button gets toggled, a terminal update resets it, or the broker disables expert trading on the account. The EA keeps evaluating, and every order is refused. Add these to the heartbeat payload and alert on false: TerminalInfoInteger(TERMINAL_TRADE_ALLOWED) , MQLInfoInteger(MQL_TRADE_ALLOWED) and AccountInfoInteger(ACCOUNT_TRADE_EXPERT) .

2. Every setup is being filtered out. A spread filter, a symbol suffix that changed after a broker migration (XAUUSD becoming XAUUSD.r), or a daily limit that never reset. The EA is healthy and finds signals, but rejects all of them. What helped me was logging every decision, including the skipped ones, with the reason: "skipped: spread 45 > max 30". Then "evaluated 200 times, took 0, all for the same reason" is an easy alert, and it points straight at the cause.

Late to this one. #9 covers the permission part well so just one more thing. Heartbeat tells you the terminal is alive and not that each EA is doing its job. What worked better for me is doing it per magic number. Take the history and count the usual gap between that EA's trades over last few months. Then alert when the current silence is like 3x longer. Scalper quiet for 6 hours is a problem. Swing EA quiet for 4 days is just tuesday.

Also check that the EA's chart is still open. Someone closes the wrong chart and that EA is simply gone.