# How to get high of a certain time period

107

How to get high of a certain time period

I want to get the high for e.g time of my forex broker

from 00:00:00 to 00:02:00

I want get the iHighest for the time period of 00:00:00 to 00:02:00 for Today

How do I achieve it , sorry for asking and thanks for helping !

269

Read the documentation, such as -

https://docs.mql4.com/series/ihighest             to find the shift

then use

https://docs.mql4.com/series/ihigh               on the shift to find the high of the bar

16820

 bxchen: How to get high of a certain time periodI want to get the high for e.g time of my forex brokerfrom 00:00:00 to 00:02:00I want get the iHighest for the time period of 00:00:00 to 00:02:00 for TodayHow do I achieve it , sorry for asking and thanks for helping ! Get the starting/ending times.Get the starting/ending bar indexGet the high for the range.learn to code and the available functions ``` #define HR2400 (PERIOD_D1 * 60)  // 86400 = 24 * 3600 int      TimeOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();                                           return( when % HR2400 );            } datetime DateOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();                                           return( when - TimeOfDay(when) );   } //datetime Tomorrow( datetime when=0){      if(when == 0)  when = TimeCurrent(); //                                          return(DateOfDay(when) + HR2400);   } //datetime Yesterday(datetime when=0){      if(when == 0)  when = TimeCurrent(); //   int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(when) - 1); //                                       return( iTime(NULL, PERIOD_D1, iD1) ); } #define HR0000 0 #define HR0002 (2*60)  // 00:02:00 datetime bod=DateOfDay(); int iM1Bod = iBarShift(NULL, PERIOD_M1, bod + HR0000); int iM102  = iBarShift(NULL, PERIOD_M1, bod + HT0002 -1); // [0:00 - 0:02) int iM1HH  = iHighest( NULL, PERIOD_M1, iM102 - iM1Bod + 1, iM1Bod); double M1HH= iHigh(NULL, PERIOD_M1, iM1HH);```
25

I don't know about this and also want to know .  I think it is a good strategy.
114

whroeder1:
 Get the starting/ending times.Get the starting/ending bar indexGet the high for the range.learn to code and the available functions

Found this thread in google and just want to correct two lines from the code from @whroeder1 (thx for that code!)

I think it should look like this

```#define HR2400 (PERIOD_D1 * 60)  // 86400 = 24 * 3600
int      TimeOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();
return( when % HR2400 );            }
datetime DateOfDay(datetime when=0){      if(when == 0)  when = TimeCurrent();
return( when - TimeOfDay(when) );   }
//datetime Tomorrow( datetime when=0){      if(when == 0)  when = TimeCurrent();
//                                          return(DateOfDay(when) + HR2400);   }
//datetime Yesterday(datetime when=0){      if(when == 0)  when = TimeCurrent();
//   int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(when) - 1);
//                                       return( iTime(NULL, PERIOD_D1, iD1) ); }

#define HR0000 0
#define HR0002 (2*60)  // 00:02:00
datetime bod=DateOfDay();
int iM1Bod = iBarShift(NULL, PERIOD_M1, bod + HR0000);
//int iM102  = iBarShift(NULL, PERIOD_M1, bod + HT0002 -1); // [0:00 - 0:02)
int iM102  = iBarShift(NULL, PERIOD_M1, bod + HR0002 -1); // [0:00 - 0:02) // <-- this was the old line (small typo HT0002 vs. HR0002)
//int iM1HH  = iHighest( NULL, PERIOD_M1, iM102 - iM1Bod + 1, iM1Bod); // <-- this was the old line
int iM1HH  = iHighest( NULL, PERIOD_M1, MODE_HIGH, iM1Bod - iM102 + 1, iM102);
double M1HH= iHigh(NULL, PERIOD_M1, iM1HH);```