Have a read of this post and reply: https://www.mql5.com/en/forum/135049
HI, went through your post. It works sometimes - in fact, when I first added the code to move stops to zero, it worked fine, and even when I moved them to 3 pips more than my entry. But once I changed some of the other criteria(aside from entry/modify) it would stop working.
This same modifying script works fine in my other experts.
thanks
What are your Broker's MODE_FREEZELEVEL & MODE_STOPLEVEL ?
Mr RaptorUK,
You are the expert here. Could you help me with the codes? Really not sure what went wrong about the Ordermodify Error 1.
void DoModify1() { int atr=ATR(1); for(int i=0;i<OrdersTotal(); i++) { RefreshRates(); bool b=OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if (!b) continue; if (OrderSymbol()!=Symbol()) continue; if (OrderMagicNumber()!=Magic) continue; if (OrderType()==OP_BUY) { if(OrderStopLoss()==0) { double sl= OrderOpenPrice()-atr*myPoint*AtrPecSL; OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,Red); } else if(OrderTakeProfit()==0 && ! IsClosePer) { double tp= OrderOpenPrice()+atr*myPoint*AtrPecTP; OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),tp,0,Green); } else if(IsClosePer && OrderTakeProfit()!=0) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),0,0,White); } } else if (OrderType()==OP_SELL) { if(OrderStopLoss()==0) { sl= OrderOpenPrice()+atr*myPoint*AtrPecSL; OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,Red); } else if(OrderTakeProfit()==0 && ! IsClosePer) { tp= OrderOpenPrice()-atr*myPoint*AtrPecTP; OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),tp,0,Green); } else if(IsClosePer && OrderTakeProfit()!=0) { OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),0,0,White); } } } }
Spawn1980:
You need to read the return values from the OrderModify() to know which one(s) fails and report the error . . . then you will have a better idea of which value you are not changing. Error 1 happens when you do an OrdrModify without changing the SL or TP . . . to avoid this check that the new SL is different to the current SL and that the new TP is different to the current TP . . . bear in mind that comparing doubles can be troublesome . . . read this thread for more info about comparing doubles:
Can price != price ?
Mr RaptorUK,
You are the expert here. Could you help me with the codes? Really not sure what went wrong about the Ordermodify Error 1.

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
Hi,
I keep getting ordermodify errors 1 and 130 when executing this code:
Please note that the "Lot" variable is predefined, and the call to the LOT() function is not being used right now.