Author: Copyright 2022, Guilherme Mendonca
Price Data Components
Series array that contains open time of each bar
Miscellaneous
It issuies visual alerts to the screen
0 Views
0 Downloads
0 Favorites
VPS_Check
ÿþ//+------------------------------------------------------------------+

//|                                                    VPS_Check.mq5 |

//|                               Copyright 2022, Guilherme Mendonca |

//|                          https://www.mql5.com/en/users/billy-gui |

//+------------------------------------------------------------------+

#property copyright "Copyright 2022, Guilherme Mendonca"

#property link      "https://www.mql5.com/en/users/billy-gui"

#property version   "1.00"



input string       desc = "VPS/MT5 Funcionando";      // # Descrição da mensagem #

input int          hh = 8;                            // # Hora de disparo #

input int          mm = 45;                           // # Minuto de disparo #

input bool         fds = true;                        // # Envia no Final de Semana? #



//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

bool check_vps=false;

int OnInit()

  {

   if(hh<0 || hh>23)

     {

      Print("Hora inválida");

      Alert("Hora inválida");

      return(INIT_FAILED);

     }

   if(mm<0 || mm>59)

     {

      Print("Minuto inválido");

      Alert("Minuto inválido");

      return(INIT_FAILED);

     }   

   

   EventSetTimer(10);



//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//---

   EventKillTimer();



  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const int begin,

                const double &price[])

  {

//---



//--- return value of prev_calculated for next call

   return(rates_total);

  }

//+------------------------------------------------------------------+

//| Timer function                                                   |

//+------------------------------------------------------------------+

void OnTimer()

  {

//---

   MqlDateTime w_day;

   TimeToStruct(TimeLocal(),w_day);



   if(!fds && (w_day.day_of_week==0 || w_day.day_of_week==6))

      return;



   if(!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))

      return;



   if(!MQLInfoInteger(MQL_TESTER))

     {

      datetime t0=_IntToTime(hh,mm);

      if(TimeLocal()>t0 && check_vps==false)

        {

         SendNotification(desc);

         Print(desc);

         check_vps=true;

        }



      if(TimeLocal()>=(t0-300) && TimeLocal()<(t0-5) && check_vps==true)

        {

         check_vps=false;

        }

     }

  }

//+------------------------------------------------------------------+

//+------------------------------------------------------------------+

//|                                                                  |

//+------------------------------------------------------------------+

datetime _IntToTime(int hour, int minutes)

  {

   string time = IntegerToString(hour) + ":" + IntegerToString(minutes);



   MqlDateTime time_str;

   TimeToStruct(StringToTime(time),time_str);



   MqlDateTime cur_str;

   TimeLocal(cur_str);

   MqlDateTime str;

   str.day=cur_str.day;

   str.year=cur_str.year;

   str.mon=cur_str.mon;

   str.hour=0;

   str.min=0;

   str.sec=0;

   datetime day=StructToTime(str);

   if(day==0)

     {

      Alert("Open D1 chart on "+Symbol());

      return(TimeCurrent()+60*60);

     }

   return (day+time_str.hour*60*60+time_str.min*60);

  }

//+------------------------------------------------------------------+

Comments