https://www.mql5.com/en/forum/124153, "Error 1 and I don't know why"
I still don't get it :(
I've seen this error generated even when the new stoploss is equal to the old stoploss. With print statements.
OrderStopLoss() != Dynamic_Stop_Sell
I'd also ran into the thread where Gordon helped you fix it. But however I've never got order_modify to be error free.
The usual response I get for this error is because order modify is setting a value which already exist. If this is the case that does not explain why it dis-reguards the OrderStopLoss() != Dynamic_Stop_Sell and proceeds with the if statements when OrderStopLoss() is clearly (=)equal-to Dynamic_Stop_Sell.
Another reason could be because I'm entering the same Tp as what it already have. But I doubt that's the case as even the Documentation on order_modify uses the OrderTakeProfit() for tp.
If someone could please just add what missing within the above code so that it'll no longer generate error#1 within the back-tester I'll appreciate it. Because at this point I've checked everything I've heard of checking.
*NewStopLoss not equal to OldStopLoss.
*NewStopLoss > OldStopLoss
*NewStopLoss is Not within the StopLevel.
Hi uzben,
Yup, you only get the error if nothing on the order is changed, so the same TP should have no effect.
I suspect your problem is that you should Normalise Dynamic_Stop_Buy(and sell).
You could try reversing the logic a bit and trouble shoot from there :-
if(OrderType()==OP_BUY){ if(OrderStopLoss()==NormaliseDouble(Dynamic_Stop_Buy,Digit_Info))break; if(OrderStopLoss()==0 || Dynamic_Stop_Buy > OrderStopLoss()){ if(Bid_Norm > Dynamic_Stop_Buy+(Stop_Info*Point_Info)){ OrderModify(Ticket,OrderOpenPrice(),Dynamic_Stop_Buy, OrderTakeProfit(),0,Green); } } }
Actually, I am tearing my hair out with the same problem. NormaliseDouble hasn't fixed it and nor did the logic reverse.
I know the coding police will want to crucify me but I have used this simple workaround :-
if(GetLastError()==1)return(true);The return(true) being the outcome of my OrderModify........aaarg!
Personally, I only trail my stops on a full pip move and don't get error 1
try
if(Dynamic_Stop_Buy > OrderStopLoss()+1*Point_Info)V
@kennyhubbard: Lol yep, if(GetLastError()==1)return(true); definitely crossed my mind. I'll go ahead and try V's method and report back on here.
@Viffer: if(Dynamic_Stop_Buy > OrderStopLoss()+1*Point_Info); if this is the answer, you'll save me some early gray hair. Thanks guys for your input. I can't test this right now. Will do later.
Edit: V's if(Dynamic_Stop_Buy > OrderStopLoss()+1*Point_Info); totally SOLVED the problem :)
Oh, the piece of code is not designed for me. I programmed if for this thread. I don't know if it's sub-pip or not and wanted it to be flexible. I'm doing these script like EA to practice my bullet-proof coding (one size fits all). I'll leave that up to the user to decide.
On another note -BB- what do you think of my Pip/Point implementation Here.
@kennyhubbard: Lol yep, if(GetLastError()==1)return(true); definitely crossed my mind. I'll go ahead and try V's method and report back on here.
@Viffer: if(Dynamic_Stop_Buy > OrderStopLoss()+1*Point_Info); if this is the answer, you'll save me some early gray hair. Thanks guys for your input. I can't test this right now. Will do later.
Edit: V's if(Dynamic_Stop_Buy > OrderStopLoss()+1*Point_Info); totally SOLVED the problem :)
I'm glad it worked out... yeah... I am assuming Point_Info makes that 1 pip. (presumably you would have just used Point if it wasn't)
V
I still don't get it :(
OrderStopLoss() != Dynamic_Stop_Sell
Don't not compare doubles for equality/inequality. Suppose SL=1.2345 and DSS=1.23450000001 They're not equal but you'll get a error 1.
if ( (Dynamic_Stop_Sell - OrderStopLoss()) >= Point ) // Now ok to move SL upSee Working with Doubles in MQL4
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Now why would this give OrderModify Error#1? Ea Attached.