You
Server Change the SL to X It is at X! Change the SL to X It is at X! Change the SL to X You are insane OrderOpenPrice() != OrderStopLoss()
The == operand. - MQL4 forum
You
Server Change the SL to X It is at X! Change the SL to X It is at X! Change the SL to X You are insane - The == operand. - MQL4 forum
Not quite true
first time he checks if the SL is @ break even
OrderOpenPrice() != OrderStopLoss()
so he is modifying the OrderStopLoss() to OrderOpenPrice()
the Second time is OrderStopLoss() == OrderOpenPrice()
It looks a bit awkward but I seem to have fixed the issue using MathRound (after multiplying by mx, which = 10000). Many thanks!
MathRound(OrderOpenPrice()*mx) != MathRound(OrderStopLoss()*mx)
Not quite true
first time he checks if the SL is @ break even
so he is modifying the OrderStopLoss() to OrderOpenPrice()
the Second time is OrderStopLoss() == OrderOpenPrice()
Do not compare doubles for equality. It has to do which EVERY computer because the way floating point is implementated. Nothing unusual with MQL4.
Print your variables
Print("OSL="+PriceToStr(OrderStopLoss()), " OOP="+PriceToStr(OrderOpenPrice()), " Equ="+( OrderStopLoss() == OrderOpenPrice() ) ); ///////////// string PriceToStr(double p){ return( DoubleToStr(p, Digits) ); }
I have some code to break even when price reaches a particular point but I keep getting OrderModify Error 1 in the journal. The code works absolutely fine and does its job of break even at the correct point, I just keep getting the error clogging up the journal after that happens.
I also tried the following but it doesn't make a difference:
Any ideas?
Edit: additional info: I only use one timeframe and one symbol, and Open Prices only for the Strategy Tester.
Edit2: Is is possible to suppress the error message?
Hi,
I'm trying to replicate the error you get . Can you post how do you calculate the LongBreakEvenPrice and ShortBreakEvenPrice ?
Do you have only 1 order open at the time and you store the open price somewhere else?
Because if you have more than 1 order, say buy orders, the LongBreakEvenPrice won't be the same for the two of them, right ?
Hi,
I'm trying to replicate the error you get . Can you post how do you calculate the LongBreakEvenPrice and ShortBreakEvenPrice ?
Do you have only 1 order open at the time and you store the open price somewhere else?
Because if you have more than 1 order, say buy orders, the LongBreakEvenPrice won't be the same for the two of them, right ?
That doesn't matter, the important condition here is
OrderOpenPrice() != OrderStopLoss()
The problem can usually be resolved by substituting
MathAbs(OrderOpenPrice() - OrderStopLoss() ) > Point()
That doesn't matter, the important condition here is
The problem can usually be resolved by substituting
I understand your point but if you cannot test the code and get the same error, how can you be sure?
Unless you use to get the ERROR 1 message in your other code or EA's and you solved it as you mentioned.
I would give your answer a thumb up any way, if I could.
I understand your point but if you cannot test the code and get the same error, how can you be sure?
Unless you use to get the ERROR 1 message in your other code or EA's and you solved it as you mentioned.
I would give your answer a thumb up any way, if I could.
In the OP's code
if (OrderType() == OP_BUY && iClose(NULL,0,0) >= LongBreakEvenPrice && OrderOpenPrice() != OrderStopLoss()) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),0,0,Yellow); }
you could simply change it to something like
if (OrderType() == OP_BUY && Bid-OrderOpenPrice()>Point()*100 && OrderOpenPrice() != OrderStopLoss()) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),0,0,Yellow); }
if you are trying to replicate the error

- 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 some code to break even when price reaches a particular point but I keep getting OrderModify Error 1 in the journal. The code works absolutely fine and does its job of break even at the correct point, I just keep getting the error clogging up the journal after that happens.
I also tried the following but it doesn't make a difference:
Any ideas?
Edit: additional info: I only use one timeframe and one symbol, and Open Prices only for the Strategy Tester.
Edit2: Is is possible to suppress the error message?