This function will close All open trades for a particual MagicNumber of EA.Code:void CloseAll() { int total = OrdersTotal(); for(int i=total-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS); int type = OrderType(); if (OrderSymbol()==Symbol() && (OrderMagicNumber() == MagicNumber)) { //-- Close open BUYs if (type == OP_BUY) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),Slippage,CornflowerBlue); //-- Close open SELLS if (type == OP_SELL) OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),Slippage,CornflowerBlue); } } return; }
Programming - editing - modification EA, Script or Indicator for MT4 OR MT5 ---- Trading on the Forex market involves substantial risks, including complete possible loss of funds and other losses and is not suitable for all members. Client should make an independent judgments as to whether trading is appropriate for him/her in light of his/her financial condition, investment experience, risk tolerance and other factors.
Tuesday, 27 November 2012
Close All Function
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment