Set automated task on specified time

To add comments, please log in or register
Ricardo de Jong
39
Ricardo de Jong  

Hello, 

I'm trying to write a simple Expert Advisor or Script that will send an overview of my current account status via an e-mail message. 

However I want to run this EA or Script on a specific time. The only way I know is using the " OnTick() "function but that will be a nightmare because my mailbox will be flooded in no time. Is there a simple way to define a time frame? for example every 10 minutes there will be a status e-mail send. 


Kind Regards,


Ricardo de Jong

//+------------------------------------------------------------------+
//|                                                       SendStatus |
//|                                  Copyright 2017, Ricardo de Jong |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+

void OnStart()
  {
   SendStatus();
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void SendStatus() //The name of the function for sending account information
  {
// SendMail function

   double AccountBalance=AccountInfoDouble(ACCOUNT_BALANCE);
   double AccountEquity=AccountInfoDouble(ACCOUNT_EQUITY);
   double AccountProfit=AccountInfoDouble(ACCOUNT_PROFIT);

   string sp="|"; // Using this as a spacer

   string header=(AccountBalance+sp+AccountEquity+sp+AccountProfit); // Using only the e-mail header information, no use for subtext.

   SendMail(header,"");
  }
//+------------------------------------------------------------------+
William Roeder
19846
William Roeder  
Ricardo de Jong: I want to run this EA or Script on a specific time. The only way I know is using the " OnTick() "function but that will be a nightmare because my mailbox will be flooded in no time.
  1. You can't run it at a specific time. You have to run it and have it wait until the specific time.
  2. It would be flooded if you don't remember the last time sent and verify that at least your 10 minutes has passed..
Anthony Garot
3612
Anthony Garot  
Run SendStatus() from the OnTimer() event, which you can set up for every 10 minutes using EventSetTimer().
Ricardo de Jong
39
Ricardo de Jong  
Anthony Garot:
Run SendStatus() from the OnTimer() event, which you can set up for every 10 minutes using EventSetTimer().

It works, thank you!!

William Roeder
19846
William Roeder  
Ricardo de Jong: It works, thank you!!

Your title was "automated task on specified time,"  not periodicly. Be specific with your questions.

Ricardo de Jong
39
Ricardo de Jong  
whroeder1:

Your title was "automated task on specified time,"  not periodicly. Be specific with your questions.

My bad, English is not my native language.


Thanks for your answer though.


Have a nice day.  

To add comments, please log in or register