EA Help, Identifying Highest High

 

Hi,

 

I am having some trouble trying to identify the highest high for the last x number of candles.

I already have a for loop running to identify other Highs and Lows.

- The for loop has to work backwards from eg 10 candles to the live candle. 

Any help is greatly appreciated

 

Thanks in advance 

 
   int highest_shift=iHighest(Symbol(),0,MODE_HIGH,10,0);
   double highest_value =High[highest_shift];
   
   //Or as 1 line
   double highest_value =High[iHighest(Symbol(),0,MODE_HIGH,10,0)];
To find the highest high of the last 10 bars including the current bar
 

That is great thanks

 

What if I didn't want to include the live candle/bar? 

 
sebwelch:

That is great thanks

 

What if I didn't want to include the live candle/bar? 

int highest_shift=iHighest(Symbol(),0,MODE_HIGH,10,0);

gets the highest shift from bar shift 0 to and including bar shift 9, a total of 10 bars 

 

Just change the last 0 to a 1, then you will get the highest shift of the last 10 closed bars. ie from the bar shift 1 to and including bar shift 10.

   int highest_shift=iHighest(Symbol(),0,MODE_HIGH,10,1);

Make sure that you read the documentation and fully understand the function