Script : Close All
-
Create a new script file: close_all.mq4
#property copyright "Copyright" #property link "..." int start(){ int total = OrdersTotal(); for(int i=total-1;i>=0;i--){ OrderSelect(i, SELECT_BY_POS); int type = OrderType(); bool result = false; switch(type){ case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red ); break; case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red ); } if(result == false){ Sleep(0); } } return(0); }