指定时间全部平仓的函数

楼主  收藏   举报   帖子创建时间:  2019-05-05 14:35 回复:0 关注量:767
函数执行在某个时间后全部平仓或删除挂单。

  1. if (Hour() >= Order_Hour)
  2. {
  3. for(cnt=0;cnt<OrdersTotal();cnt++)
  4. {
  5. // check selection result because order may be closed or deleted at this time!
  6. OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
  7. if (OrderSymbol()==Symbol())//check for opened position and symbol
  8. {
  9. if (OrderType()==OP_SELLSTOP && OpenBuys>0) OrderDelete( OrderTicket());
  10. if (OrderType()==OP_BUYSTOP && OpenSells>0) OrderDelete( OrderTicket());
  11. if (Hour() >= CloseOrdersHour && Minute() >= 45 && OrderType()==OP_SELL)
  12. OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
  13. if (Hour() >= CloseOrdersHour && Minute() >= 45 && OrderType()==OP_BUY)
  14. OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
  15. }
  16. }
  17. }
打赏