Print("Lots is, ",Lots);
Print("MathRound(Lots/0.01) is, ",MathRound(Lots/0.01));
Print("Lots with MathRound, ",NormLotsRound);
Print("Lots with NormalizeDouble, ",NormLotsDouble);
I'm running this script to test a function in my EA that auto calculate lot based on % and a Delta, i wrote the revelant code only with numeric value, it's the first time i get this kind of problem running it for several week.
If you run the Script i'm getting a Lots that is 0.6896662958841845,
when i'm rounding it with Lot step of my broker (0.01) i get 69.0 that is right.
But when then, i'm multiplying it for lot step (again 0.01) i get 0.6900000000000001. Why this is happening?
Tried also using NormalizeDouble and i get wrong value, what should i do? The correct lot should be 0.69!
I don not use normalizedouble in EA code, this script was made just to test why i get wrong number, lot is beign adjusted with lotstep, max lot and min lot from broker and i check for freemargin also.
I'm going to read everything you psoted, i hope i can get everything working, i have no coding background, so a lot of "easy" thing are out of my knowledge and English is not my native language.
Thank you for helping. I'll write back if i need more practical examples.
I readed everything, point 2. and 3. are fully implemented in my code, the script i posted is just with plain number i get from ea with no "safety" logic just to test why i get this strange numbers.
I readed Can price != price ? - MQL4 forum, but i do not understand what i should do in my case, i don't need to compare 2 double, it's clear how to do it the topic.
I have a double, 69.0 in this case, multiplied by *0.01, and i should get 0.69, isntead i get 0.6900000000000001.
What kind of function or calculation should i use to turn this double with 16th decimal in something that my OrderModify function can accept?