STEP11 How to get the highest candle

The highest candle can be useful for technical Expert Advisors

If you have ever read a book about technical chart analysis, you might know that it is all about new highs and new lows. To calculate the highest candle within the last x candles, you can use this simple code (simply paste into new and empty EA template)

double HighestCandleM1;
void OnTick()
HighestCandleM1= CheckForHighestCandle();
Comment ("Number of the highest candle within the last 10 candles before the current candle: "+ HighestCandleM1);
double CheckForHighestCandle()
double High[];
double Calc1= ArrayMaximum(High,0,11);
return Calc1;

Here is how it looks like


If you want to use it within you own EA, simply copy and paste the CheckForHighestCandle() function and add the two lines in the OnTick function into the appropriate place in your own code.

Would you like to know the highest candle within the last 100 candles instead? Simply change the number 11 in the two lines above the line

return Calc1;

to 101.