Get the recent High and Low Price

 

Hi there, 

I am new to mql4 and to this forum. 

I try to get the most recent High and Low. What I don't want is the highest or lowest price in a certain period of time. I really just want the most recent High or Low Price of the candle as in this picture:


So I cant use iHigh or iLow because I just want the most recent High / Low and not in a period. I tried to calculate the last High within the window of the last 30 candles. Starting by the most recent candle, counting backwards in the chart. To Identify the High I thought I can compare the Price or High of the current Candle with the High of the Last candle. If the current price is bigger we will be in an uptrend or at least in buidling a new High. But if the current Price is below I can count backwards and compare the High of the Candle with the High of Candle+1 (the next candle backwards in time) until the Candle+1 High is smaller than the Candle High. 

Long story short: 

for (int i = 1; i <= Window; i++)
   {    
      if (High[i] > Highest && High[i++]<High[i]){    
         LastHigh = High[i];
         Print("Last High was detected at ", LastHigh);
         }
   }

But that is not working. 

Looking for your advice or an example function for identifying most recent High and Low. I'm sure there is a simple solution and I am overthinking as usual. 
Thank you!


Best regards, 

HansTheTrader

Reason: