Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via Visa QIWI Wallet
MetaQuotes Software Corp.
Moderator
177439
MetaQuotes Software Corp. 2009.11.04 16:06 

New article Working with Doubles in MQL4 has been published:

In this note we will consider a typical programming errors, that occurs while working with double numbers in MQL4 programs.

Author: MetaQuotes Software Corp.

MQL4 Comments
16309
MQL4 Comments 2009.11.05 22:36  

Great article! I was getting a lot of error code # 1's in my OrderModify calls for trailing stops. I kinda figured it was due to calling the function with no change in the parameters, but wasn't sure how to fix it. Using NormalizeDouble in my check for trailing stops took care of the problem.


Also was getting error code 4107 from my OrderSend function calls when using Strategy Tester. It seems Strategy Tester is using historical values at 5 decimal points, when I'm testing a currency pair with 4 decimal points. Using NormalizeDouble(Ask,Digits), or NormalizeDouble(Bid,Digits) in my OrderSend function took care of the error. Cool!

forexrun
5
forexrun 2016.04.10 14:14  

I am new to mql programming and the issue 1 discussed here( Verifying the numerical numbers) was a show stopper for me. Lucky I saw this within 6 months after starting mql programming. This I hope is sorted in mql5 and never heard of in any other high level languages that I am familiar with.

Alain Verleyen
Moderator
28702
Alain Verleyen 2016.04.10 19:52  
forexrun:

I am new to mql programming and the issue 1 discussed here( Verifying the numerical numbers) was a show stopper for me. Lucky I saw this within 6 months after starting mql programming. This I hope is sorted in mql5 and never heard of in any other high level languages that I am familiar with.

The same is true in all programming languages which are using double data type.
abcmql4
11
abcmql4 2016.10.29 20:28  
Hello and thanks for all this information,

I am a big problem now, since it had never required

I need to work and pass the result in a "double" a "string", but this number is 106 decimal, need them all, as I do?

put the link of what I put in the forum, where I explain what I need, thank you very much aid they can offer me

 https://forum.mql4.com/74365 


I hope you can help me. 

Mladen Rakic
8527
Mladen Rakic 2016.10.29 22:11  
abcmql4:
Hello and thanks for all this information,

I am a big problem now, since it had never required

I need to work and pass the result in a "double" a "string", but this number is 106 decimal, need them all, as I do?

put the link of what I put in the forum, where I explain what I need, thank you very much aid they can offer me

 https://forum.mql4.com/74365 


I hope you can help me. 

You can not do that that way (double has 15 significant digits)

If you need only the string you can declare it as a string right away and then you will not lose information - like this :

   string SE = "result  = 1.23456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678";      

But any conversion to and from a double will leave you with only 15 accurate digits result

You can also check this : https://en.wikipedia.org/wiki/List_of_arbitrary-precision_arithmetic_software  for arbitrary precision arithmetic libraries and software capable of doing it

/
To add comments, please log in or register