execution by intervals

To add comments, please log in or register
fxnew5
69
fxnew5  

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

Marco vd Heijden
Moderator
12454
Marco vd Heijden  
//+------------------------------------------------------------------+
//|                                        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");
  }
//+------------------------------------------------------------------+
fxnew5
69
fxnew5  

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")


To add comments, please log in or register