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

 

A good option will be to combine both:

1. place a limit order and check it was placed. this confirms the ea is working in connection with borker.

2. send HB to external plataform, may be Discord, at certain time intervals or when failing to place limit order.

3. Anoither EA, sitting in a different VPS, perhaps a different provider, checks for frequency of HB and messages received from the parent EA. If frequency of arrival of HB is violated or a message arrived saying the limit order failed to be placed, this external ea sends email to user that soemthing is wrong.

perhaps a daily message should also be send saying everything is fine, so that one can suspect soemthing is wrong with the secundary ea.

 
Fernando Carreiro #:

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.

You don't need a webhosting or VPS. There are some companies offering this service for free (or paid of course), you just need to send an HTTP request from your code every X seconds. If it fails you will get some notifications from the service. It's very easy.
 
that would be super convenient... without mentioning the name of the provider, do you know what is the name of the service?
 
Camilo Mora #: that would be super convenient... without mentioning the name of the provider, do you know what is the name of the service?
Maybe something like "Heartbeat Monitoring"?
 

For those interested, I have created a simple EA that sends a HB to a heartbeat monitor. Based primarily from this post. I created a function, such that you can send the HB after checking for criteria other than time. When the EA fails to send a HB you get an email saying something is going wrong. I hope it helps. If you know how to make it better, please improve.


input int HeartbeatInterval = 60; // Heartbeat interval in seconds
string MonitorID = "Your_ID";
string APIKey = "Your_Api";

void OnTick() 
{
   static datetime lastHeartbeatTime = 0;
   
   // Send heartbeat at specified interval
   if(TimeCurrent() - lastHeartbeatTime >= HeartbeatInterval) 
   {
      SendHeartbeat(MonitorID, APIKey);
      lastHeartbeatTime = TimeCurrent();
   }
}

void SendHeartbeat(string ID, string Key) 
{
   string url = "https://cronitor.link/p/" + ID  + "/" + Key;
   string headers = "";
   string response_header;

   char postfxa[],fbfxa[];

   ResetLastError();
   
   int Trd=WebRequest("POST",url,headers,500,postfxa,fbfxa,response_header);
   if(Trd==-1)
     {
      MessageBox("Go to Tools then Options and on the Expert Advisors tab add the URL for https://cronitor.link", "Error", MB_ICONINFORMATION);
     }
     Print(Trd);
}
How to monitor your VPS terminals?
How to monitor your VPS terminals?
  • www.mql5.com
Most of us use a VPS to run our trading EA's 24/7, but how to monitor if these terminals are up and running?  What if they crash, or shut-down due to an update?  How do I get notified