Unbelievable!!!
The result of this code is 0.0700000000001
string lottDD; void OnTick(void) { lottDD=StringToDouble(0.07); Print(lottDD); }
I use this code:
when my order lots is 0.07 (Only this number!!) i get Print from lots and it is 0.070000000001
My order open with 0.07 but when I get and Print order lotage by
I see lotage is 0.070000000001 .
Please not that it accord only for 0.07 lots!!
Do you have any Idea about this ?
Floating point numbers aren't 100% accurate and 0.07 doesn't have an exact representation in floating point.
prg_mt4: The result of this code is 0.0700000000001
Floating point has infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented exactly.
(like 1/10.)
Double-precision
floating-point format - Wikipedia, the free encyclopedia
See also The == operand. - MQL4 programming forum
Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.
Floating point has infinite number of decimals, it's your not understanding floating point and that some numbers can't be represented
exactly. (like 1/10.)
Double-precision
floating-point format - Wikipedia, the free encyclopedia
See also The == operand. - MQL4 programming forum
Print out your values to the precision you want with DoubleToString - Conversion Functions - MQL4 Reference.
Thank you for your answer
I used MathFloor(x/lotStep)*lotStep
but result is 0.0700000001
Actually I don't know how can I create 0.07
this is very bad problem for me . EA close my order immediately because my order lotage is more than acceptable risk management .
Could you exactly tel me how can I make 0.07 lotage in my code
Thank you very very much
What part of "some numbers can't be represented exactly" was unclear?
If you loose the extra $0.000000000001 is that unacceptable?
What part of "some numbers can't be represented exactly" was unclear?
If you loose the extra $0.000000000001 is that unacceptable?
Hello Williams
this issue solved with this formula :
if(P_lots-Lots_F[sd_1]>-0.0000001) {close all positions}
It's Ok now .
Thank you for your help 👍👍
What part of "some numbers can't be represented exactly" was unclear?
If you loose the extra $0.000000000001 is that unacceptable?
Dear william, can you answer to my question in this page ?
- 2019.09.30
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I use this code:
when my order lots is 0.07 (Only this number!!) i get Print from lots and it is 0.070000000001
My order open with 0.07 but when I get and Print order lotage by
I see lotage is 0.070000000001 .
Please not that it accord only for 0.07 lots!!
Do you have any Idea about this ?