![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
I needed to call the order modify from the "int start()" function when "If(IsNewCandle())" is called too. Therefore, on EVERY hour close, the "void OrderModify" that modify's the PENDING order if the orderstoploss > iMA-ATR, will be modified and calibrated accordingly.
So that is now doing it's job properly :) Now to read until my eyes bleed... :)
This is the issue . . . (similar for the OP_SELL)
. . . and when you get an error 1 it is because OrderStopLoss() == BuyStopPrice so you are modifying the order to have the same StopLoss value, hence error 1 so now you are wondering how on one hand OrderStopLoss() == BuyStopPrice and on the other hand OrderStopLoss() < BuyStopPrice
Did you follow the link in the post and read it till your eyes bled ? I bet you didn't . . . https://www.mql5.com/en/forum/146380 if you keep ignoring this issue it will keep catching you out and you will keep wasting time . . . get to grips with it, understand it, don't suffer from it any longer, be happy
except with zero never compare doubles for equality < Might this be what I was looking for by WHRoeder...?
if (a > b)
if (a >= b)
if (a != b)
except with zero never compare doubles for equality < Might this be what I was looking for by WHRoeder...?
To be perfectly honest, no I don't understand... I did experiment with writing it out and printing the comparisons though...
1.51234000001 is not the same as 1.51234000002 but from the point if view of a price they are both 1.51234 so are the same . . . so they are the same but one is greater than the other. It's all to do with the way floating point numbers are represented in binary, it's inexact so there is generally a little error here and there . . .
Have a look at this: floating point numbers
But why would NormalizedDouble, Digits not sort that out? Why are the extra unnecessary decimal places be included? I appreciate the fact you do not need to use NormalizeDouble on predefined variables, but whats the point in using NormalizeDouble on non predefined variables, and then trying to compare them when they'll never match up :s?
Strange!
If I wanted to do "If(Bid > OrderOpenPrice())" that wouldnt work would it? Would I need to do the rules stated above, on every comparison statement? i.e. "If(Bid - OrderOpenPrice() > Point / 2.)?
Oh and what If(Bid == OrderOpenPrice()), is there anything I need to do with that statement?
But why would NormalizedDouble, Digits not sort that out? Why are the extra unnecessary decimal places be included? I appreciate the fact you do not need to use NormalizeDouble on predefined variables, but whats the point in using NormalizeDouble on non predefined variables, and then trying to compare them when they'll never match up :s?
NormalizeDouble does not fix the issue, it does not turn 1.51234000001 into 1.51234 it just "messes" with it in a different way . . . so by using it you are hoping that it messes with all your values in the same way.
If I wanted to do "If(Bid > OrderOpenPrice())" that wouldnt work would it? Would I need to do the rules stated above, on every comparison statement? i.e. "If(Bid - OrderOpenPrice() > Point / 2.)?
Yes, if you wanted to be sure your comparison was giving you an accurate result, yes.
Oh and what If(Bid == OrderOpenPrice()), is there anything I need to do with that statement?
Ok thanks - I have dramatically reduced the OrderModify error 1 - however, I am still getting a little bit now and again? Seems like it is the MA_trail void? Also, how would I correctly write "If(Bid == OrderOpenPrice())?
Your eyes aren't bleeding enough . . .
You could do something like this:
!( MathAbs(FirstPrice - SecondPrice) > HalfAPoint )
be careful about the !
From here: https://www.mql5.com/en/forum/136997/page4#781986