Try this
void DeleteAllPendingOrders() { for (int i = OrdersTotal() - 1; i >= 0; --i) { if (OrderSelect(i, SELECT_BY_POS) && OrderSymbol() == _Symbol) { ENUM_ORDER_TYPE orderType = (ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE); // Check if the order is pending if (orderType == ORDER_TYPE_BUY_LIMIT || orderType == ORDER_TYPE_SELL_LIMIT || orderType == ORDER_TYPE_BUY_STOP || orderType == ORDER_TYPE_SELL_STOP || orderType == ORDER_TYPE_BUY_STOP_LIMIT || orderType == ORDER_TYPE_SELL_STOP_LIMIT) { bool result = OrderDelete(OrderTicket()); if (!result) { Print("Failed to delete Order ", OrderTicket(), " Error: ", GetLastError()); } } } } }

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
Im trying to close all pending orders at the start of a new day,
But im getting errors