Set automated task on specified time

 

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,"");
  }
//+------------------------------------------------------------------+
 
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..
 
Run SendStatus() from the OnTimer() event, which you can set up for every 10 minutes using EventSetTimer().
 
Anthony Garot:
Run SendStatus() from the OnTimer() event, which you can set up for every 10 minutes using EventSetTimer().

It works, thank you!!

 
Ricardo de Jong: It works, thank you!!

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

 
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.  

Reason: