Download MetaTrader 5
To add comments, please log in or register
Do you have Mac OS? Find out how to install MetaTrader on it!
sebwelch
18
sebwelch 2015.08.20 06:43 

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 

Keith Watford
Moderator
7887
Keith Watford 2015.08.20 07:06  
   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
sebwelch
18
sebwelch 2015.08.20 07:10  

That is great thanks

 

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

Keith Watford
Moderator
7887
Keith Watford 2015.08.20 07:37  
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. 

/
To add comments, please log in or register