函数执行在某个时间后全部平仓或删除挂单。
- if (Hour() >= Order_Hour)
- {
- for(cnt=0;cnt<OrdersTotal();cnt++)
- {
- // check selection result because order may be closed or deleted at this time!
- OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
- if (OrderSymbol()==Symbol())//check for opened position and symbol
- {
- if (OrderType()==OP_SELLSTOP && OpenBuys>0) OrderDelete( OrderTicket());
- if (OrderType()==OP_BUYSTOP && OpenSells>0) OrderDelete( OrderTicket());
- if (Hour() >= CloseOrdersHour && Minute() >= 45 && OrderType()==OP_SELL)
- OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet);
- if (Hour() >= CloseOrdersHour && Minute() >= 45 && OrderType()==OP_BUY)
- OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
- }
- }
- }
|