How to code a message indicating that an EA is NOT working on VPS?

 

I deployed an EA in MQL5 VPS since October 2024 and it worked fine until Jan 15 2025.. I presume Metatrader migrated the EA to a different sever and in that process the EA was removed. Fortunately, all the positions open were at profit and this issue was not negative but it could have been. MQL5 offers very little costumer warranty so one really has to be paying attention.

I really like the idea of deploying an EA in the web and sort of leaving it alone. The question is,,,is there a way to check an EA is working by code? I was thinking may be adding  command to send a message once a day or so, saying the EA was working... any thought how can this be done?


If you look at the logbook, at about 10pm, Metatrader started something, loaded the EA, but then it failed, and the ea is removed. basically, the error could have been spoted by counting the number of EAs and indicators loaded, if this number changes, may be send a message , saying soemthing when wrong. any thoughts?


 

Your topic has been moved to the section: Expert Advisors and Automated Trading
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893

⚠️You have been advised on this before, so please pay attention.

 
Camilo Mora: I really like the idea of deploying an EA in the web and sort of leaving it alone. The question is,,,is there a way to check an EA is working by code? I was thinking may be adding  command to send a message once a day or so, saying the EA was working... any thought how can this be done?

Yes, the easiest and most robust method is to implement a "heartbeat" function, where you send out a message at a regular interval.

The receiving end could be a web server, that monitors it and then sends you a Telegram or Discord message, or even an eMail, when the "heartbeat" has been missed a set count or a timer expires.

 
Fernando Carreiro #:

Yes, the easiest and most robust method is to implement a "heartbeat" function, where you send out a message at a regular interval.

The receiving end could be a web server, that monitors it and then sends you a Telegram or Discord message, or even an eMail, when the "heartbeat" has been missed a set count or a timer expires.

to keep this within the mql5 framework, one could create another EA reading the heartbreats... basically, the target ea sends HB to DIscord, another EA located in a other VPS reads them, and when HB stop being received, this later EA sends email with warning... nice... thanks Fernando.
 
Camilo Mora #:
to keep this within the mql5 framework, one could create another EA reading the heartbreats... basically, the target ea sends HB to DIscord, another EA located in a other VPS reads them, and when HB stop being received, this later EA sends email with warning... nice... thanks Fernando.

Probably you can set a far away limit order (which is guaranteed to not trigger and is in allowed price range by your broker), and periodically update it's price. When you can monitor the changes from other terminals.

 
Stanislav Korotky #:

Probably you can set a far away limit order (which is guaranteed to not trigger and is in allowed price range by your broker), and periodically update it's price. When you can monitor the changes from other terminals.

great idea. And also send more info in the order comment if possible

 
Stanislav Korotky #:

Probably you can set a far away limit order (which is guaranteed to not trigger and is in allowed price range by your broker), and periodically update it's price. When you can monitor the changes from other terminals.

hmmm... but I will still need to be paying attention to the VPS, not to mention that the order is placed with the broker, so the EA may still fail but the broker may still show the position pending. I do nor see how this option will allow me to know if the EA stopped working in the VPS...
 
Camilo Mora #: hmmm... but I will still need to be paying attention to the VPS, not to mention that the order is placed with the broker, so the EA may still fail but the broker may still show the position pending. I do nor see how this option will allow me to know if the EA stopped working in the VPS...

If you update the order periodically, then when the EA fails and no longer updates it, then you can detect that, from any other terminal, even manually from a mobile device.

For exempla, every hour on the hour, you cancel the previous pending order and place a new one. It's creation time thus indicates when last it was created. So, if the currently placed order is older than one hour, then you can assume that the EA is no longer functioning because it did not replace the pending order.

Another way, is not to do a cancel and place a new order, but to simply update the existing one with new details (volume, price, stops, expiration, etc.) but in a way that you can detect if it is a recent change or not.

 

But how can one do this in practical terms? I would need to open the terminal and check if the order is pending, which defeat the purpose of what we are trying to do. Becuase the EA is sitting in a vps, any time I open the account, in theory i can see the vps lookbook. 


One could have the same account in two vps, with two diffent eas ( the original one and another one monitoring), but as far I know one account cannot be set simultaneously in two vpss...

The idea is to get a warning of kind, indicating that a ea operating from a vps has stopped working.

 
Camilo Mora #:

But how can one do this in practical terms? I would need to open the terminal and check if the order is pending, which defeat the purpose of what we are trying to do. Becuase the EA is sitting in a vps, any time I open the account, in theory i can see the vps lookbook. 

One could have the same account in two vps, with two diffent eas ( the original one and another one monitoring), but as far I know one account cannot be set simultaneously in two vpss...

The idea is to get a warning of kind, indicating that a ea operating from a vps has stopped working.

For an automated method, simply run an EA on your home computer (or another VPS) to monitor the order and then send you a notification when the order is not updated as expected.

 

Personally, I still prefer the "heartbeat" method, because I can simply rent a simple webhosting service at a much lower cost than renting a VPS.

There are even "free" options for webhosting which you can easily program a simple PHP script (or some other method) to receive the "heartbeat" and then send you a simple email to a specific address (when the heartbeat fails).

Your mobile phone can easily notify you when it receives the email on that dedicated address.