0

In MT4 custom indicator/EA, how do I work with time please?

E.g every day 08:05, I would like to check the High/Low of this 5min bar. I don't know how to work with this 5 minute period only.

Many thanks Vic

Victor
  • 659
  • 3
  • 8
  • 19

1 Answers1

0
//inputs:
input int InpMinuteYouNeed = 5;
input int InpHourYouNeed = 8;

void OnTick(){
   if(Hour()==InpHourYouNeed && Minute()==InpMinuteYouNeed){

   }
}

Also you may found the following functions interesting:

 datetime time = StrToTime("8:05");
 int hourYouNeed = TimeHour(time);
 int minuteYouNeed = TimeMinute(time); 

then use these values same as InpHourYouNeed but of course they must be global or in struct. This must be enough for the first time.

Daniel Kniaz
  • 4,603
  • 2
  • 14
  • 20