开仓时间我设定的是time>091500 and time<220000,然后到22:00 全部清仓并且不再开仓,可是实际运行的时候22点以后和9.15分以前都有开仓,时间设定根本没用啊怎么?
代码如下,我到底哪里错了呢?
//适用模式:“走完一根K线以后”
//若用户模式选为“固定时间间隔”,请将"交易条件"中的CLOSE改为OPEN,避免信号闪烁。
//中间变量
MA1:=MA(CLOSE,A);
MA2:=MA(CLOSE,B);
手数:=ss;
//交易条件
开多平空条件:=CROSS(c,MA1);//开多平空条件
开空平多条件:=CROSS(MA2,c);//开空平多条件
//交易系统
平空:SELLSHORT(开多平空条件,手数,MARKET);
平多:SELL(开空平多条件,手数,MARKET);
开多:BUY(开多平空条件,手数,MARKET);
开空:BUYSHORT(开空平多条件,手数,MARKET);
当前持仓:HOLDING,COLORGRAY,LINETHICK0;
当前资产:ASSET,NOAXIS,COLORGRAY;
//注意交易系统先开后平的原则,开仓条件加入 :
time>091500 and time<220000;
//若在开仓时间已经持有仓位,,到22:00 全清掉
if time>=220000 then begin
sell(1,0,marketr);
sellshort(1,0,marketr);
end
手数:=ss;
//交易条件
开多平空条件:=CROSS(c,MA1);//开多平空条件
开空平多条件:=CROSS(MA2,c);//开空平多条件
tt:=time>091500 and time<220000;
//交易系统
平空:SELLSHORT(开多平空条件 and tt,手数,MARKET);
平多:SELL(开空平多条件 and tt,手数,MARKET);
开多:BUY(开多平空条件 and tt,手数,MARKET);
开空:BUYSHORT(开空平多条件 and tt,手数,MARKET);
当前持仓:HOLDING,COLORGRAY,LINETHICK0;
当前资产:ASSET,NOAXIS,COLORGRAY;
//注意交易系统先开后平的原则,开仓条件加入
//若在开仓时间已经持有仓位,,到22:00 全清掉
if time>=220000 then begin
sell(1,0,marketr);
sellshort(1,0,marketr);
end
怎么第一次加载上去测试好好的,然后再运行的时候就一个成交都没有了?
内盘外盘我都测试了一下,都是一个成交都没有
我用一分钟都试了今年的历史数据也没有一个成交??重新启动了两次也是这样
是北京时间坐标
策略代码是新建的
数据测试的是本周这三天的1分钟豆一连续数据
一个成交都没有
不行
variable:dt=0,kt=0;
ss:=stkindi('','时间.tt',0,5);
a1:=ref(HIGH,22);
a2:=ref(HIGH,10);
a6:=ref(l,22);
a7:=ref(l,10);
a3:=c>a1 and c>a2;
a8:=c<a6 and c<a7;
mm:=ref(h,1)=hhv(h,3) or ref(h,2)=hhv(h,3) or ref(h,3)=hhv(h,3);
nn:=ref(l,1)=llv(l,3) or ref(l,2)=hhv(l,3) or ref(l,3)=hhv(l,3);
if mm then bj:=1;
if nn then bj:=-1;
nn1:=barslast(mm);
nn2:=barslast(nn);
if c<ref(l,nn1+1) and bj=1 then i:=1;
if c>ref(h,nn2+1) and bj=-1 then i:=-1;
uu3:=cross(i=1,0.5);
uu4:=cross(i=-1,0.5);
tt:=(time>=090512 and time<=112500) or (time>=133500 and time<=145500) or (time>=210500 and time<=225500);
if uu3 and a8 and holding=0 and tt then begin
buyshort(holding=0,1,market);
end
if uu4 and a3 and holding=0 and tt then begin
buy(holding=0,1,market);
end
b1:=c<ref(l,barslast(c>o));
if a8 and b1 and holding=0 and tt then begin
buyshort(holding=0,1,market);
end
b2:=c>ref(h,barslast(c<o));
if a3 and b2 and holding=0 and tt then begin
buy(holding=0,1,market);
end
n1:=hhvbars(vol,10);
h10:=ref(h,n1);
if holding<0 and c>h10 then sellshort(1,0,thisclose);
l10:=ref(l,n1);
if holding>0 and c<l10 then sell(1,0,thisclose);
//if holding<0 and c>a2 then sellshort(1,0,thisclose);
//if holding<0 and uu4 then sellshort(1,0,thisclose);
//if holding<0 and c>ref(h,22) then sellshort(1,0,thisclose);
//if holding>0 and c<ref(l,22) then sell(1,0,thisclose);
//if holding>0 and c<a7 then sell(1,0,thisclose);
// if holding>0 and uu3 then sell(1,0,thisclose);
if (time>=112500 and time<=113000) or (time>=145500 and time<=150000) or (time>=225500 and time<=230000) then begin
收盘平多:sell(1,0,thisclose);
收盘平空:sellshort(1,0,thisclose);
end
用这段代码试试