for (int i = OrdersTotal() - 1; i >= 0; i--) {
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {
if (OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, 3, Blue);
if (OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, 3, Red);
}
Sleep(750);
}
}
Probably the problem is the Sleep(750), each position is closed only after nearly 1 seconds after the position before, thats a lot of time, if I have 50 or more positions to close.
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.
Hi,
I using this function to close all my position:
Probably the problem is the Sleep(750), each position is closed only after nearly 1 seconds after the position before, thats a lot of time, if I have 50 or more positions to close.
Its a good idea to delete the sleep?
For a better solution I would be very grateful.