execution by intervals

 

does anyone have the idea for a (complete)code part, which makes sure, an EA (alternatively) an indicator is executed only at certain time intervals, let's say every 30 seconds etc.?


for eventual hints thanks a lot in advance

 
//+------------------------------------------------------------------+
//|                                        30 Seconds to Profits.mq4 |
//|  Copyright 2017, Marco van der Heijden,MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, Marco van der Heijden,MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create timer
   EventSetMillisecondTimer(30000);// 30 Sec
      
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- destroy timer
   EventKillTimer();
      
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
//---
   Alert("30 Sec gone by");
  }
//+------------------------------------------------------------------+
 

thanks a lot, Marco, for this fast (and working) feedback!!

since you're an expert in the MT5 area, may I ask another question:

is there a code fragement/idea how to adress past values from global variables (or to "record them") while ticks (and Bars) are coming in ?  let's say GlobalVariableGet("CustomVar") gets the Bar0-value. Now the Bar1-value would be interesting to adress (or to be "stored")


Reason: