多单全部平仓的写法

楼主  收藏   举报   帖子创建时间:  2019-05-05 14:35 回复:0 关注量:181
函数执行多单全部平仓。

  1. void CloseBuys(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_BUY)
  12. {
  13. if(OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Blue))
  14. {
  15. i--;
  16. }
  17. RefreshRates();
  18. }
  19. }
  20. }
打赏