|
|||||||
| Register in Forex TSD! | |
|
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time). Click here to register and get more information |
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Function to effectively close all orders.
I have been using this function to try and close all my orders, both pending and open. However for some unknown reason, there's always unclosed orders remaining. How do I ensure that every single pending/open order closes?
Code:
// close all open and pending orders
void closeAllOrders() {
int total = OrdersTotal();
for (int i=total-1; i>=0; i--) {
if (OrderSelect(i, SELECT_BY_POS)) {
if (OrderType() == OP_BUY) {
OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 3, Red);
} else if (OrderType() == OP_SELL) {
OrderClose(OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 3, Red);
} else if (OrderType() > 1) {
OrderDelete(OrderTicket());
}
}
}
} // end closeAllOrders()
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sleep function in EA between orders | icek | Metatrader 4 | 2 | 06-11-2007 04:10 PM |
| modify orders and close pending orders | bkgridley | Questions | 8 | 05-23-2007 09:49 PM |
| SHI Silvertrend close orders EA?? | fxbrandon | Expert Advisors - Metatrader 4 | 1 | 11-29-2006 08:17 PM |
| Script close all orders | paulosilva555 | Metatrader 4 | 1 | 02-17-2006 04:19 PM |
| close all orders | mas | Metatrader 4 | 2 | 02-15-2006 08:14 AM |