Converting 4 Decimals into 5 Decimals ---- Help

 

Hey,

I have a series of custom indicatios all of which have the IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS) set which displays on my chart to 5 decimal places however if I call the indicator in my EA using iCustom I only get a result returned to 4 decimal places???

I can use Doubletostr which will give me 5 decimal places but I can use this data type for the send order function?! If I use NormalizeDouble to 5 digits it still only gives me 4 decimal places.

Im stuck anyone got any ideas? is there a way I can convert string to double??

Cheers

Mark

 
meath12:

Hey,

I have a series of custom indicatios all of which have the IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS) set which displays on my chart to 5 decimal places however if I call the indicator in my EA using iCustom I only get a result returned to 4 decimal places???

I can use Doubletostr which will give me 5 decimal places but I can use this data type for the send order function?! If I use NormalizeDouble to 5 digits it still only gives me 4 decimal places.

Im stuck anyone got any ideas? is there a way I can convert string to double??

Cheers

Mark

There is string to double function as well

https://docs.mql4.com/convert/StrToDouble

 
robofx.org wrote >>

There is string to double function as well

https://docs.mql4.com/convert/StrToDouble

Yeah that doesn't seem to work....

I have the following iCustom:

double Resistance = iCustom(NULL,0,"CUSTOMIND",1000,20,1,1000,0,1);

which returns 1.4828

if I alter that to:

string Resistance = DoubleToStr(iCustom(NULL,0,"FX9",1000,20,1,1000,0,1),5);

I get: 1.48282

If I then do:

double val = StrToDouble(Resistance);

I get: 1.4828

If I change that to: NormalizeDouble(StrToDouble(Resistance),5)

I also get: 1.4828

I can't figure out how to keep that 5 decimal???

 

I think I know what you are missing.

The Print() statement, by default, will deliver doubles to 4 decimal places.


So:

If you have a double for which you need to amend the number of digits - use NormalizeDouble().

If you have a double which you need to display, then use DoubleToStr() upon it in your Print() call, otherwise Print() will deliver it with 4 digits regardless.


Hope this helps clear things up for you.


CB

Reason: