空单全部平仓函数

楼主  收藏   举报   帖子创建时间:  2019-05-05 14:35 回复:0 关注量:145
该函数执行空单全部平仓。调用中可以自行加条件。

  1. void CloseSells(int MagicNumber, int Slippage)
  2. {
  3. for(int i = 0; i < OrdersTotal(); i++)
  4. {
  5. // already closed
  6. if(OrderSelect(i, SELECT_BY_POS) == false) continue;
  7. // not current symbol
  8. if(OrderSymbol() != Symbol()) continue;
  9. // order was opened in another way
  10. if(OrderMagicNumber() != MagicNumber) continue;
  11. if(OrderType() == OP_SELL)
  12. {
  13. if (OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, Red))
  14. {
  15. i--;
  16. }
  17. RefreshRates();
  18. }
打赏