某时间点平仓及删除挂单

楼主  收藏   举报   帖子创建时间:  2019-05-05 14:33 回复:0 关注量:38
函数执行在设定时间到达即平仓所有持仓单及删除未成交挂掉。

  1. extern double Lots = 0.1;
  2. extern int ChasStart = 10;
  3. extern int ChasStop = 22;
  4. extern int Step = 15;
  5. extern int TP = 200;
  6. if (TimeHour(TimeCurrent())==ChasStop && TimeMinute(TimeCurrent())==0)
  7. {
  8. i=0;
  9. total = OrdersTotal();
  10. for(i = 0; i <= total; i++)
  11. {
  12. OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
  13. if(OrderMagicNumber() == 12321)
  14. {
  15. if (OrderType()==OP_BUY)OrderClose(OrderTicket(),OrderLots(),Bid,3,Green);
  16. if (OrderType()==OP_SELL)OrderClose(OrderTicket(),OrderLots(),Ask,3,Green);
  17. if (OrderType()>1)OrderDelete(OrderTicket());
  18. }
  19. }
  20. }
打赏