Solved.
As suspected, "double" variable is the problem.
Computers have always had hard time representing "double" (aka, fractional/real numbers) onto computers. "real" numbers are only represented as "estimates" inside a computer and therefore, what may appear to us as 1.2831 would actually be something like 1.283100031 and only rounded to appear 1.2831
So I simply "integerize" all those doubles by multiplying it with 10000. 1.2831 will now be 12831 and all ends well.
As suspected, "double" variable is the problem.
Computers have always had hard time representing "double" (aka, fractional/real numbers) onto computers. "real" numbers are only represented as "estimates" inside a computer and therefore, what may appear to us as 1.2831 would actually be something like 1.283100031 and only rounded to appear 1.2831
So I simply "integerize" all those doubles by multiplying it with 10000. 1.2831 will now be 12831 and all ends well.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The Comment before the if statement shows that OrderStopLoss being equal to SL and OrderTakeProfit equal to TP as well. Yet, the IF statement does not agree. I looked at the Journal and see that it went to send the OrderModify command to the server:
I have this subcode within a loop and the loop will keep looping while (OrderStopLoss != SL || OrderTakeProfit != TP). And since it could not perform the != operation properly, it kept looping indefinitely and keep sending an OrderModify to the server.
It does sometimes able to do the != operation properly and exits from the loop, but sometimes it does not.
Was it because all of the above values are double and MT4 engine could not properly compare "double" values properly? This has always been the problem with "non-integer" numbers with computers ever since... I'll try to "integerize" the number and see what will come out...
Any help is most welcome.
Thanks!