Closing order get freeze on MT4
anh tuan2:
Hello.
Here is my code. it passed the compile but freeze in MT4. Could anyone please help.
Sorry for my bad English. I'm not a native speaker.
Thank you very much.
if( (OrderType()==OP_BUY && signal == "sell") || (OrderType() == OP_SELL && signal == "buy") ) { CloseAllTradeThisPair(); } double CloseAllTradeThisPair() { int total = OrdersTotal(); for(int i=total-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); int type = OrderType(); if (OrderSymbol() == Symbol()) { 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); }
Hello.
Here is my code. it passed the compile but freeze in MT4. Could anyone please help.
Sorry for my bad English. I'm not a native speaker.
Thank you very much.