使用传统图表固定轮询1秒模式运行,
开平仓信号在11:30、15:15收盘前5秒执行,其他时间使用REF引用上周期,
实盘ref(,1)开仓信号正常,但ref(,1)平仓未执行,什么原因?
下面代码有什么问题吗?
TT1:=(currenttime>=091500 and currenttime<112955) or (currenttime>=130000 and currenttime<151455),colorred,linethick0;
TT2:=(currenttime>=112955 and currenttime<113000) or (currenttime>=151455 and currenttime<151500),colorred,linethick0;
TT3:=(currenttime>=060000 and currenttime<091500) or (currenttime>113005 and currenttime<130000) or (currenttime>151505 and currenttime<235000) ,colorred,linethick0;
B1:=((islastbar=1 and TT1 and ref(D1,1)) or (islastbar=1 and TT2 and D1) or (islastbar=1 and TT3 and D1) or (islastbar=0 and D1));
B2:=((islastbar=1 and TT1 and ref(P1,1)) or (islastbar=1 and TT2 and P1) or (islastbar=1 and TT3 and P1) or (islastbar=0 and P1));
S1:=((islastbar=1 and TT1 and ref(K1,1)) or (islastbar=1 and TT2 and K1) or (islastbar=1 and TT3 and K1) or (islastbar=0 and K1));
S2:=((islastbar=1 and TT1 and ref(P11,1)) or (islastbar=1 and TT2 and P11) or (islastbar=1 and TT3 and P11) or (islastbar=0 and P11));
EXITLONG:B2,TFILTER;
EXITSHORT:S2,TFILTER;
ENTERLONG:B1;
ENTERSHORT:S1;
D1---开多信号
P1---平多信号
K1---开空信号
P11---平空信号
要具体分析问题,需要全部代码
其他代码在执行时肯定没有问题,
有个现象,
当上根k线出开空信号,使用ref(K1,1)开空时,黄色三角标志指向现在的K线,
当上根k线出平空信号,使用ref(P11,1)开空时,黄色三角标志仍然指向上根K线,这就不正常。
实盘5分钟周期,当在13:30这根k线出开空信号,使用ref(K1,1)开空时,交易发出以及成交的时间都仍然是13:30,这个是怎么回事?
按照这个逻辑,当在13:55这根k线出开空信号,使用ref(K1,1)开空时,交易发出以及成交的时间都仍然是13:55,而因为轮询1秒,就错过了?
那也不对,当开空时,信号在13:35这根k线一直都有,而平空时,信号在14:00这根k线就一直没有。
图表交易有信号才会下单。按照你的描述那么就是开仓条件在对应的时间段是满足的,而平仓条件在对应的时间段是不满足的
所以需要全部的代码,看看平仓条件为什么在对应的时间段上不满足条件
可能是ref(,1)、islastbar=0、islastbar=1同时使用有逻辑冲突,造成无平仓信号,弃用islastbar就正常了。