Does anyone know what's wrong with this code?

 

 I'm trying to get the half price value between 52 weeks high and 52 weeks low.

But it's not coming out right, does anyone know what's wrong with this code? 

  

double ThisYearHigh = iHighest(NULL,1440,3,50,0);  // Calculation for Highest price inside range.
double ThisYearLow  = iLowest(NULL,1440,3,50,0); // Calculation for lowest price inside range.
double HalfPrice = (ThisYearHigh+ThisYearLow) /2;
 
double val;
//--- calculating the highest value on the 20 consecutive bars in the range
//--- from the 4th to the 23rd index inclusive on the current chart
   int val_index=iHighest(NULL,0,MODE_HIGH,20,4);
   if(val_index!=-1) val=High[val_index];
   else PrintFormat("Error in call iHighest. Error code=%d",GetLastError());
 
Omar AlKassar:
Your reply has nothing to do with getting the price value in between 52 weeks high and 52 weeks low.
 

I use the following code to find the HH and LL of price range ...

double HH =  NormalizeDouble(iHigh(Symbol(), 10080, iHighest(Symbol(),10080,MODE_HIGH,52,1)),Digits);
double LL =  NormalizeDouble(iLow(Symbol(), 10080, iLowest(Symbol(),10080, MODE_LOW,52,1)), Digits);  

 then,

double HP = NormalizeDouble((HH+LL)/2,Digits);

 I wish this will work for you ...

 
Osama Shaban:

I use the following code to find the HH and LL of price range ...

 then,

 I wish this will work for you ...

Thanks, I will test it out.
Reason: