I have this code and prints r
2014.04.17 22:35:29.633 2014.04.10 04:48 px EURUSD,Daily: X modify
2014.04.17 22:35:29.633 2014.04.10 04:48 px EURUSD,Daily: 0
2014.04.17 22:35:29.633 2014.04.10 04:48 px EURUSD,Daily: 1.3718 # 1.387-0.005 # 1.3918
2014.04.17 22:35:29.633 2014.04.10 04:48 px EURUSD,Daily: 0.0152 > 0.005 && 1.382>1.382
2014.04.17 22:35:29.632 2014.04.10 04:48 px EURUSD,Daily: 1 && 1
problem is that mql4 evaluated 1.382>1.382 AS true
WHY????
Hi vosy,
I haven't read your code thoroughly but a quick glance gives two possible causes of the problem.
1. Double data types are actually accurate to 15 significant figures but without using the DoubleToString function they are shortened and rounded to a display of 3 decimal places when displayed with the Comment and Print functions. Even though they are shortened for display purposes they are still accurate beyond 3 decimal places and any comparisons will check the full value, so it may be possible that the first 1.382 is greater than the second 1.382 but display rounding is hiding the true and full value and displaying them both as 1.382. When the first 1.382 could be 1.3822 and the second 1.382 maybe 1.3821 for example. Add the DoubleToString function to display the full value to see if this is what is happening.
2. Another theory but it is a long shot but worth a try is many of your comparisons could be evaluated incorrectly due to a lack of brackets. For example,
if(H-OrderOpenPrice()>BE && H-SL>OrderStopLoss())
Try rewriting it with brackets to ensure the code is being interpreted as you require, for example,
if(((H-OrderOpenPrice())>BE) && ((H-SL)>OrderStopLoss()))
Hope these suggestions help,
Noddy
- 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 have this code and prints r
2014.04.17 22:35:29.633 2014.04.10 04:48 px EURUSD,Daily: X modify
2014.04.17 22:35:29.633 2014.04.10 04:48 px EURUSD,Daily: 0
2014.04.17 22:35:29.633 2014.04.10 04:48 px EURUSD,Daily: 1.3718 # 1.387-0.005 # 1.3918
2014.04.17 22:35:29.633 2014.04.10 04:48 px EURUSD,Daily: 0.0152 > 0.005 && 1.382>1.382
2014.04.17 22:35:29.632 2014.04.10 04:48 px EURUSD,Daily: 1 && 1
problem is that mql4 evaluated 1.382>1.382 AS true
WHY????