iHigh returns rounded number.

 

When getting a value of the last daily bar using iHigh it returns only rounded number and I need all digits for precision.

double high = iHigh(NULL,PERIOD_D1,1); returns 1.329 while the high is 1.32899

 I cannot use DoubleToStr as I need the value as "double" for further processing.

Any idea how to get all digits?

 
colos7:

When getting a value of the last daily bar using iHigh it returns only rounded number and I need all digits for precision.

double high = iHigh(NULL,PERIOD_D1,1); returns 1.329 while the high is 1.32899

 I cannot use DoubleToStr as I need the value as "double" for further processing.

Any idea how to get all digits?

It happens already,  what makes you think you are getting a rounded value ?  how are you seeing this value ?  show your code.
 
RaptorUK:
It happens already,  what makes you think you are getting a rounded value ?  how are you seeing this value ?  show your code.


I use

double high = iHigh(NULL,PERIOD_D1,1); 

Alert (high);

 

yesterday EURUSD high was  1.32899 but Alert window shows 1.329.

 
colos7:


I use

double high = iHigh(NULL,PERIOD_D1,1); 

Alert (high);

 

yesterday EURUSD high was  1.32899 but Alert window shows 1.329.

void Alert( ...)
Data of double type output with 4 decimal digits after point. To output with more precision use DoubleToStr() function.

Alert

 
deVries:
void Alert( ...)
Data of double type output with 4 decimal digits after point. To output with more precision use DoubleToStr() function.

Yep,  but shouldn't that show 1.3289  ?  not 1.329 ?

 

colos7:


yesterday EURUSD high was  1.32899 but Alert window shows 1.329.

I have a different high for yesterday,  can you try this please and let us know what you get.

double high = iHigh(NULL,PERIOD_D1,1); 

Alert ("High - string ", DoubleToStr(high, Digits) );   //  Edit,  sorry, should have included Digits
 
I see, thanks! I fought I was going crazy. So the "high" value is correct after all. Didn't know about Alert limitations. 
 
RaptorUK:

Yep,  but shouldn't that show 1.3289  ?  not 1.329 ?

 

The double was 1.32899     then it is not 1.3289  but  1.3290  

we see if last digit is o then the last digit is not printed in Alert

You can check

   double high = 1.32899;
//----
   Alert(high);
 
colos7:
I see, thanks! I fought I was going crazy. So the "high" value is correct after all. Didn't know about Alert limitations. 
I did,  I knew Alert, Print and Comment all just print a maximum of 4 digits,  I didn't know they also rounded values up.
 
deVries:

The double was 1.32899     then it is not 1.3289  but  1.3290  

we see if last digit is o then the last digit is not printed in Alert

You can check


OK,  so the 4 digit treatment is not a truncation as I assumed it is in fact a rounding ?  Thanks,  something else I have learned today :-)
Reason: