Notification if VPS still working

 

Hi folks, 

I would like to check every hour or every 30 minutes if VPS I'm using for my EA is working.

I wrote the following code, but I think there is some better way to input "times" every time that the function was called, instead of one line for each hour.

What do you guys think?


//+------------------------------------------------------------------+   
datetime vpspush=0;

void check_vps()
   {
    if(TimeCurrent()==_StringToTime("09:10") || 
       TimeCurrent()==_StringToTime("10:00") || 
       TimeCurrent()==_StringToTime("11:00") || 
       TimeCurrent()==_StringToTime("12:00") || 
       TimeCurrent()==_StringToTime("13:00") || 
       TimeCurrent()==_StringToTime("14:00") || 
       TimeCurrent()==_StringToTime("15:00") || 
       TimeCurrent()==_StringToTime("16:00") || 
       TimeCurrent()==_StringToTime("17:00")
       )
       {
        if(vpspush!=TimeCurrent())
          {
           Print("VPS Working - "+TimeToString(TimeCurrent(),TIME_MINUTES|TIME_SECONDS));
           SendNotification("VPS Working - "+TimeToString(TimeCurrent(),TIME_MINUTES|TIME_SECONDS));
           vpspush=TimeCurrent();
          }
       }
    else
      {
       vpspush=0;
      }
 
   }
//+------------------------------------------------------------------+   
 
  1.     if(TimeCurrent()==_StringToTime("09:10") || 
           TimeCurrent()==_StringToTime("10:00") || 
           TimeCurrent()==_StringToTime("11:00") || 
           TimeCurrent()==_StringToTime("12:00") || 
           TimeCurrent()==_StringToTime("13:00") || 
           TimeCurrent()==_StringToTime("14:00") || 
           TimeCurrent()==_StringToTime("15:00") || 
           TimeCurrent()==_StringToTime("16:00") || 
           TimeCurrent()==_StringToTime("17:00")
    Those will be true only if you get a tick in the first second of the hour. You will do better if the last notification time is over an hour.
  2. There isn't a better way; if the VPS is down, code doesn't run.
 
William Roeder:
  1. Those will be true only if you get a tick in the first second of the hour. You will do better if the last notification time is over an hour.
  2. There isn't a better way; if the VPS is down, code doesn't run.

1. Yes. No problem. But also I think if I use this function on "Void OnTimer", it should works also.

2.  "if the VPS is down, code doesn't run."

That's exactly my idea. If I realize that I did not received the last VPS message, for example, each every 30 minutes, I will know that something's wrong.


But anyway. If you know, could you show me a better way to write this code?  

Virtual hosting for MetaTrader 5
Virtual hosting for MetaTrader 5
  • www.mql5.com
The fastest VPS server for forex trading from the MetaTrader 4/5 terminal developers
 
William Roeder:
  1. Those will be true only if you get a tick in the first second of the hour. You will do better if the last notification time is over an hour.
  2. There isn't a better way; if the VPS is down, code doesn't run.

With a new candle kn m1 a tick be there, so that code works

Reason: