Download MetaTrader 5

Does anyone know what's wrong with this code?

To add comments, please log in or register
The Market has more than 400 indicators. Try any of them!
Cuong Truong
4245
Cuong Truong 2016.06.17 14:33 

 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;
Omar Alkassar
2424
Omar Alkassar 2016.06.17 14:57  
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());
Cuong Truong
4245
Cuong Truong 2016.06.17 14:59  
Omar AlKassar:
Your reply has nothing to do with getting the price value in between 52 weeks high and 52 weeks low.
Osama Shaban
1448
Osama Shaban 2016.06.17 15:51  

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 ...

Cuong Truong
4245
Cuong Truong 2016.06.17 17:46  
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.
To add comments, please log in or register