Download MetaTrader 5
To add comments, please log in or register
Thousands of developers have already published their products in the Market. Join them!
matt_
37
matt_ 2015.10.18 11:55 

Does anyone know how I could send email alerts at certain times?

I am looking to do this every hour, the Sendmail function is easy enough but I'm stuck on a Time loop? 

 Thank you in advance 

honest_knave
969
honest_knave 2015.10.18 12:02  

Lots of ways. Here is one:

int OnInit()
  {
   EventSetTimer(1);
   return(INIT_SUCCEEDED);
  }

.....

void OnTimer()
  {
   static int LastHour=-1;
   int ThisHour=TimeHour(TimeLocal());
   if(ThisHour!=LastHour)
     {
      SendMail("My Subject","My Message");
      LastHour=ThisHour;
     }
  }
whroeder1
13641
whroeder1 2015.10.18 12:03  
Check the current time vs the last sent time; no loop required.
matt_
37
matt_ 2015.10.18 12:21  
Great thanks
/
To add comments, please log in or register