Hello everybody. I heard there is a way to cancel all open trades in mt4.
This is because Ive run out of funds with many trades still open. I dont want to
deposit any more as these are large trades and will eat my money.
Is there aaaaaaan indicator or something to multi close all trades in MT4??
Thanks in advance..
int start() { int total = OrdersTotal(); for(int i=total-1;i>=0;i--) { bool trret=OrderSelect(i, SELECT_BY_POS); int type = OrderType(); bool result = false; switch(type) { //Close opened long positions case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, CLR_NONE ); break; //Close opened short positions case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, CLR_NONE ); break; //Close pending orders case OP_BUYLIMIT : case OP_BUYSTOP : case OP_SELLLIMIT : case OP_SELLSTOP : result = OrderDelete( OrderTicket() ); } if(result == false) { if (GetLastError()>0) Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() ); Sleep(3000); } } return(0); }@ allanmurray55

Mehmet Bastem:
//Close opened long positions case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, CLR_NONE ); break; //Close opened short positions case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, CLR_NONE ); break;
Nothing wrong with using ask and bid, but there is no need to use them if you have just selected a trade, both buys and sells can be closed with OrderClosePrice().
I would advise that the code is written as a script. Otherwise, as an EA, if it is accidentally left running it will close all newly opened trades immediately (when a new tick comes in).
Nothing wrong with using ask and bid, but there is no need to use them if you have just selected a trade, both buys and sells can be closed with OrderClosePrice().
I would advise that the code is written as a script. Otherwise, as an EA, if it is accidentally left running it will close all newly opened trades immediately (when a new tick comes in).
There is no harm in writing this way, anyway

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello everybody. I heard there is a way to cancel all open trades in mt4.
This is because Ive run out of funds with many trades still open. I dont want to
deposit any more as these are large trades and will eat my money.
Is there aaaaaaan indicator or something to multi close all trades in MT4??
Thanks in advance..