某时间点平仓及删除挂单
函数执行在设定时间到达即平仓所有持仓单及删除未成交挂掉。extern double Lots = 0.1;
extern int ChasStart = 10;
extern int ChasStop = 22;
extern int Step = 15;
extern int TP = 200;
if (TimeHour(TimeCurrent())==ChasStop && TimeMinute(TimeCurrent())==0)
{
i=0;
total = OrdersTotal();
for(i = 0; i <= total; i++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber() == 12321)
{
if (OrderType()==OP_BUY)OrderClose(OrderTicket(),OrderLots(),Bid,3,Green);
if (OrderType()==OP_SELL)OrderClose(OrderTicket(),OrderLots(),Ask,3,Green);
if (OrderType()>1)OrderDelete(OrderTicket());
}
}
}
页:
[1]