I'd say it's hard to operate on a patient in a spacesuit. You've posted a compiled file here, not open-source code (*.mq4). I have a feeling that you took a ready-made script somewhere (did you check it in its natural form for performance?), changed something in the code and it stopped doing what you need. If the original code behaved normally, then look where and what you changed and check that it works after each change.
GarKain: how to modify Buy and Sell orders separately?
if (OrdersTotal()>0)
{ for (int i=OrdersTotal()-1; i>=0; i--)
{ if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{ if (OrderType()==OP_BUY) // или OP_SELLOrderModify(OrderTicket(), ...);
} } }
Can you please tell me how to deal with EA looping and loss of functionality in this case? I am still using restart, which is very inconvenient. I am using restart which is very inconvenient. Thank you in advance.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Throw in the current graph
I would be inclined to think that the error lies in the code itself. Surgical intervention in the script itself is necessary.
Here's the script itself...
Here's the script itself...
I would be inclined to think that the error lies in the code itself. Surgical intervention in the script itself is necessary.
Maybe changing the gasket would help
how do I modify Buy and Sell orders separately?
if (OrderType()==OP_BUY && Open[0]>Low[steploss] && OrderStopLoss()<trailstopbuy){
OrderModify(OrderTicket(),OrderOpenPrice(),trailstopbuy,OrderTakeProfit(),0,Blue);
return(0);
}
if (OrderType()==OP_SELL && Open[0]<High[steploss] && OrderStopLoss()>trailstopsell){
OrderModify(OrderTicket(),OrderOpenPrice(),trailstopsell,OrderTakeProfit(),0,Blue);
return(0);
}
so what?
how to modify Buy and Sell orders separately?
if (OrdersTotal()>0){
for(int g=OrdersTotal()-1; g>=0; g--){
OrderSelect(g,SELECT_BY_POS);
if (OrderMagicNumber()==2563 && OrderType()==OP_BUY){
if (Open[0]<=Low[steploss]){
OrderClose(g,1,Bid,3,Red);
return(0);
}
if (GradusEDBuy==true){
OrderClose(g,1,Bid,3,Red);
return(0);
}
}
}
if (OrderMagicNumber()==2563 && OrderType()==OP_SELL){
if (Open[0]>=High[steploss]){
OrderClose(g,1,Ask,3,Red);
return(0);
}
if (GradusEDSell==true){
OrderClose(g,1,Bid,3,Red);
return(0);
}
}
}