每天白盘与夜盘收盘前5分钟停止交易,并且平掉持仓怎么写?
你本地程序运行周期是什么周期?这个和周期有关。1分钟,5分钟周期相对好处理,其他周期代码就要复杂点。
abb1:timetot0(CLOSETIME(0))-timetot0(time),NODRAW;//当前时间距离白盘收盘K时间
abb2:timetot0(CLOSETIME(1))-timetot0(time),NODRAW;//当前时间距离夜盘收盘K时间 仅有夜盘情况下有效
收盘平仓时间判断:(abb1<5*60 and abb1>=0) or (abb2<5*60 and abb2>=0);
if 收盘平仓时间判断 then //收盘平仓
begin
sell(holding>0,holding,market);
sellshort(holding<0,holding,market);
end
//开仓条件里面加上 not(收盘平仓时间判断)
buy(开多条件 and not(收盘平仓时间判断),1,MARKET);
buyshort(开空条件 and not(收盘平仓时间判断),1.MARKET);