I've searched and this issue has been addressed many times. but I have been unable to find the solution.
I feel that there may be a glaringly obvious mistake in my code that I just can't see.
Have you read this thread ? Can price != price ?
Also is there a reason why a double with 5 digits only prints with 4?
I have to use DoubleToStr to see all digits.
Where you go wrong .....
Look to result OSL (old stop loss) and SL (StopLoss you tried to get)
Print("Order SL = ",DoubleToStr(OSL,6),". New SL = ",DoubleToStr(SL,6));
This line is giving you the result
If you try to modify the OrderStopLoss() with new value same as old value you get
OrderModify Error 1
it is on your sell trade you get this error
in that case choose something like
if(SL<OSL-Point)// && SL !=0 && MathAbs(SL-Ask)>freezerange && MathAbs(OSL-Ask)>freezerange)
Have you read this thread ? Can price != price ?
Yes, it's how Print() works, read the Documentation, it tells you to use DoubleToStr() so you are doing what you need to . . .Yes I have read that, but to be honest, most of it is beyond my comprehension.
What I don't understand is that when the order is sent, the EA uses the High or Low of the range to set the StopLoss.
Then, in the next tick, it gets the High or Low of the same range which is exactly the same, so when it is tested by the if function, the OrderModify should be skipped,
The bars in the range are all closed, so they cannot have changed.
Where you go wrong .....
Look to result OSL (old stop loss) and SL (StopLoss you tried to get)
This line is giving you the result
If you try to modify the OrderStopLoss() with new value same as old value you get
OrderModify Error 1
it is on your sell trade you get this error
in that case choose something like
iI tried that and it seems to work some, but not all the time
I don't have much hair as it is and in danger of tearing it all out :)
Yes I have read that, but to be honest, most of it is beyond my comprehension.
OK, give up on coding if it is too hard . . . seriously, if you want to compare double values then you need to understand (comprehend) what is written in that thread, if it takes you 5 hours to get it you must.
You get an error 1 because your old SL == your new SL,
it is as simple as that.
Why does your test fail ?
if(SL < OSL)
. . . because you are comparing doubles without doing it properly. Read the thread . . .
iI tried that and it seems to work some, but not all the time
I don't have much hair as it is and in danger of tearing it all out :)
if(SL<OSL-(2*Point))
don't modify every Point normally i do it if the distance is atleast a pip
and these two lines do NOTHING
NormalizeDouble(SL,5); NormalizeDouble(OSL,5);
Thank you so much :)
You made me look closer at the description of the Normalize function and I now see that it doesn't permanently change the value of the variable.

- 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've searched and this issue has been addressed many times. but I have been unable to find the solution.
I feel that there may be a glaringly obvious mistake in my code that I just can't see.
This is part of the code
I don't really see the need to Normalize as the SL is not calculated, it is the high of a recent range.
When I run this in strategy tester, I will get thousands of OrderModify Error 1, one after another.
I just don't see why when it is only supposed to modify the order if SL is smaller than OSL, yet the print shows them to be exactly the same
Can somebody please tell me where I am going wrong?
Also is there a reason why a double with 5 digits only prints with 4?
I have to use DoubleToStr to see all digits.