怎么写在收盘前3分全平仓,包扩夜盘,有人平种有夜盘,有的又没有夜盘,可以在多平种加载
你是要所有收盘时间都平仓还是说只是夜盘收盘和白盘下午的收盘?
[此贴子已经被作者于2021/4/26 10:46:55编辑过]
INPUT:N(3,1,200,1);
isNight:not(OPENTIME(1)=130000);//判断是否有夜盘
//白盘平仓条件
ab:=timetot0(CLOSETIME(0))-time0,NODRAW;//当前K线时间距离收盘K线结束倒计时
ab3:=timetot0(CLOSETIME(0))-timetot0(dynainfo(207)),NODRAW;//当前时间距离收盘K时间
cd1:(ab<N*60 and ab>=0 and (not(ISLASTBAR))) or (ISLASTBAR and ab3>=0 and ab3<N*60);
//夜盘平仓条件
abb:=timetot0(CLOSETIME(1))-time0,NODRAW;
abb3:=timetot0(CLOSETIME(1))-timetot0(dynainfo(207)),NODRAW;
cd2:(abb<N*60 and abb>=0 and (not(ISLASTBAR))) or (ISLASTBAR and abb3>=0 and abb3<N*60);
cd:(isNight and (cd2 or cd1)) or (not(ISNIGHT) and cd1);
if cd then //兼顾实际交易时候的信号和历史回测信号
begin
sell(holding>0,holding,market);
sellshort(holding<0,holding,market);
DRAWICON(1,h,1);
end
信号是出在最后一个K上。所以上面代码适用于固定轮训。如果要走完K的话,你把N改大即可。
[此贴子已经被作者于2021/4/26 11:29:31编辑过]