I want to get the highest bar from

 

1PM to 4PM for example,

I know that I need to use :

High[iHighest(NULL,0,MODE_HIGH,20,4)];

but instead of from 4 and 20 what should I put?

Thanks..

 

Maybe this helps

int iBarShift( string symbol, int timeframe, datetime time, bool exact=false)
Search for bar by open time. The function returns bar shift with the open time specified. If the bar having the specified open time is missing, the function will return -1 or the nearest bar shift depending on the exact.

 
but how I can get the exact time..?
 

hey i got same problem :) but my problem is converting logic into more less code, faster and not so many stupid conversion :(


iTime() is useful for me, to get datetime to be used on iBarShift()

is there any better logic/shorter way to do this?
 
roi:

1PM to 4PM for example,

I know that I need to use :

High[iHighest(NULL,0,MODE_HIGH,20,4)];

but instead of from 4 and 20 what should I put?

H1 chart:
#define  ONEPM 13
#define FOURPM 16
int fourPM=0; while( TimeHour(Time[fourPM]) != FOURPM ) fourPM++;
int High1To4 = High[iHighest(NULL,0,MODE_HIGH, FOURPM-ONEPM+1,FourPM)];
Smaller TF:
#define  ONEPM 13
#define FOURPM 16
for (int shift4PMH1=0; true; shift4PMH1++){
   datetime time4PM = iTime(NULL, PERIOD_H1, shift4PMH1);
   if (TimeHour(time4PM) == FOURPM ) break;
}
datetime time1PM = time4PM - (FOURPM-ONEPM)*3600;
int from     = iBarShift(NULL, 0, time4PM),
    to       = iBarShift(NULL, 0, time1PM)),
    High1To4 = High[iHighest(NULL,0,MODE_HIGH,to-from+1,from)];
 

thank you..

will try it..

 

I try this:

But High1To4 Value shows: "1" only all the time.not giving highest value.

#define  ONEPM 13
#define FOURPM 16
int fourPM=0; while( TimeHour(Time[fourPM]) != FOURPM ) fourPM++;
int High1To4 = High[iHighest(NULL,0,MODE_HIGH, FOURPM-ONEPM+1,fourPM)];
 
sheriffonline:

I try this:

But High1To4 Value shows: "1" only all the time.not giving highest value.


 double val;
  // calculating the highest value on the 20 consequtive bars in the range
  // from the 4th to the 23rd index inclusive on the current chart
  val=High[iHighest(NULL,0,MODE_HIGH,20,4)];

WHRoeder made a mistake in his example giving help.....

it is not integer High1To4 it has to be double

 
That post was 3 years ago when I was the noob.
#define HR2400 86400       // 24 * 3600
int      TimeOfDay(datetime when){  return( when % HR2400            );    }
datetime DateOfDay(datetime when){  return( when - TimeOfDay(when)   );    }

#define  ONEPM 46800 // 13
#define FOURPM 57600 // 16
datetime now = TimeCurrent(),  // or Time[0]
         bod = DateOfDay(now), // Beginning of the day midnight
         hr1300 = bod + ONEPM,
         hr1600 = bod + FOURPM;
if(hr1600 > now) return; // too early
int      i1300  = iBarShift(NULL,0, hr1300),
         i1600  = iBarShift(NULL,0, hr1600),
         ihh    = iHighest(NULL,0,MODE_HIGH, i1300-i1600, i1600+1); // Not including 4pm bar
double   hh     = High[ihh];                                        // 1PM to 4PM
Reason: