Newbie problem - with a basic function

 

I am learning this new launguage while trying to do some liitle things.

Following is the sample code in the Start function to define a user function.

I have 2 problems here.

1. The way I defined the function and/or called the does not look right. Hence I am getting lot of compilation errors.

2. In the function, I need to find the highest and lowest price of the last 5 bars.

For ex, after 15 GMT candle is closed, I want to pick the highest and lowest price among 15,14,13,12,11 candles..

Once I get the highest and lowest, I want to average out ( Highest + Lowest/2) and pass the same to function..

How do I do that ? Can some one please help me in this ?

end_hour = hour()

IF end_hour = 15
int average = get_highlow();

else

Print "It's not time yet";


------------------------

//functoin to determine average value

double get_highlow ()

{

int i;

int j;

for (i=0;i<5;i++;)

/./ from the last closed bar, identify the highest and lowest of the last 5 bars (Includes the last closed bar)

}

 

https://docs.mql4.com/series/iHighest

https://docs.mql4.com/series/iLowest


int start(){

   int liHour = Hour();
   if (liHour  == 15){
      double ldAVG = dGetHighLow();
   } else {
      Print("blah");
   }
}

double dGetHighLow(){
   
   double ldHH = High[iHighest(NULL,0,MODE_HIGH,5,0)];
   double ldLL = Low[iLowest(NULL,0,MODE_LOW,5,0)];
   return((ldHH+ldLL)/2.0);
}
hth (code not tested)
 

Thank you very much. I will compile and see if I am getting any errors.