To 6 decimal places or more

 

I am needing to calculate to 6 decimal places, but in mql, it seems as though the greatest precision is double at 4 decimal places. Can anyone tell me if there is a way to run calculations to 6 or more decimal places?

Thanks

 

Try This

MQL documentation isn't very explicit about double precision number formatting. But I know from other languages and a little experimentation that the double provides at least 15 decimal digits of precision. I'm not sure why you state that it is 4 digits.

Floating point - Wikipedia, the free encyclopedia

Working with Doubles in MQL4 - MQL4 Articles

 

Hi powercouple,

I'm not a mql "guru" bat as far as I know should be enough to write this at the beginning of your code:

int init()

{

IndicatorDigits(6); // or whatever number you need...

...

...

...

Best Regards

 
brax64:
Hi powercouple,

I'm not a mql "guru" bat as far as I know should be enough to write this at the beginning of your code:

int init()

{

IndicatorDigits(6); // or whatever number you need...

...

...

...
Best Regards

This is true, as the indicator is editable. And what about the case, "sewn" in MT4? For example, ADX.

 

...

It can be done only for custom indicators (changing the precision of display)

To do the same thing for the built in ones you need to make it "custom" first and then you can change the precision. Here is a simple example how you can do that for adx. Upper is with precision set to default 4 digits and lower is set to to precision 8

PS: internally the all work with implied precision for double type variables

Conieco:
This is true, as the indicator is editable. And what about the case, "sewn" in MT4? For example, ADX.
Files:
test_adx.mq4  2 kb
test_adx.gif  26 kb
 

Is there a way where I can run the calculations to 6 or more decimal places? Please help.

 
powercouple:
I am needing to calculate to 6 decimal places, but in mql, it seems as though the greatest precision is double at 4 decimal places. Can anyone tell me if there is a way to run calculations to 6 or more decimal places? Thanks

Most likely way off track here but seems unclear exactly what MT area you referring to, so here's my blurb...

If you mean your "mql" then you just may be caught out by Print() or Comment() which only outputs 4 places by default

Refer to MetaEditor's Toolbox (ctrl-T) Help tab "MQL4 Reference - Conversion functions" DoubleToStrfunction which allows up to 8 places. eg: Print(DoubleToStr(aBIGdoubleNumber,8));

To get 16 places put this at top of source file: #include

and call DoubleToStrMorePrecision(yourDoubleValue,1..16)

eg: Print(DoubleToStrMorePrecision(aBIGdoubleNumber,16));

yourRef: find below snippet in library file stdlib.mqh via MetaEditor's Navigator (ctrl-D) under "libraries"

//+------------------------------------------------------------------+

//| up to 16 digits after decimal point |

//+------------------------------------------------------------------+

string DoubleToStrMorePrecision(double number,int precision)

...

april
Is there a way where I can run the calculations to 6 or more decimal places? Please help.

Perhaps above help...