How to make the advisor to run in the last 30 sec every hour?

To add comments, please log in or register
FX-Krilon
23
FX-Krilon  

Hi,


I want the Expert to run anytime in the last 30 seconds every hour (1H bars). I.e. anytime between XX.59.30 to XX.59.59 every hour. And only to be run once. Maybe I am just searching in the wrong way but I can only find how to run the EA at the start of the bar.


Thank you in advance

Taras Slobodyanik
34269
Taras Slobodyanik  
Well, catch the beginning of the bar, and then wait for  XX.59.30
FX-Krilon
23
FX-Krilon  

Thank you,

Helped put my thoughts in the right direction


//Krilon

iRick
185
iRick  
FX-Krilon:

Hi,


I want the Expert to run anytime in the last 30 seconds every hour (1H bars). I.e. anytime between XX.59.30 to XX.59.59 every hour. And only to be run once. Maybe I am just searching in the wrong way but I can only find how to run the EA at the start of the bar.


Thank you in advance

Just add this in as a condition


&& Minute() == 59

&& Seconds() >= 30

Siti Latifah
19086
Siti Latifah  
//timeframe H1

datetime endtime = Time[0]+Period()*60;

if(endtime-TimeCurrent()<=30) { do something ....}
lippmaje
1037
lippmaje  
   static bool isCharged=true;
   MqlDateTime dt;
   TimeCurrent(dt);
   if(dt.min==59 && dt.sec>=30 && isCharged) { FireLasers(); isCharged=false; }
   if(dt.min==00 && !isCharged) isCharged=true;
Like this maybe. Place it inside OnTick().
nicholi shen
2392
nicholi shen  
bool is_trade_time(int last_n_seconds, ENUM_TIMEFRAMES tf=PERIOD_H1)
{
   datetime stop_time = iTime(_Symbol, tf, 0) + PeriodSeconds(tf);
   datetime start_time = stop_time - last_n_seconds;
   datetime curr_time = TimeCurrent();
   return (curr_time >= start_time && curr_time < stop_time);
}
To add comments, please log in or register