该函数执行空单全部平仓。调用中可以自行加条件。
- void CloseSells(int MagicNumber, int Slippage)
- {
- for(int i = 0; i < OrdersTotal(); i++)
- {
- // already closed
- if(OrderSelect(i, SELECT_BY_POS) == false) continue;
- // not current symbol
- if(OrderSymbol() != Symbol()) continue;
- // order was opened in another way
- if(OrderMagicNumber() != MagicNumber) continue;
- if(OrderType() == OP_SELL)
- {
- if (OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Red))
- {
- i--;
- }
- RefreshRates();
- }
|