variable:c1=0,loss_num=0,win_num=0,next_num=0,first_open=0,下次开仓量=0,上次开仓量=0;
variable:loss1=0,loss2=0,loss3=0,loss4=0;
VARIABLE:loss_per=0;
variable:n2:=4,n3:=20,n1:=5,m1:=2,m2:=2;
MA5:MA(CLOSE,n2);
MA10:MA(CLOSE,n3);
CONDBUY:=CROSS(MA5,MA10);
CONDSELL:=CROSS(MA10,MA5);
平多开空:=CONDSELL and HOLDING>=0;
平空开多:=CONDBUY and HOLDING<=0;
d:=date+19000000;
日期条件:=if(d>20201001,1,0);
回测开始时间:BARSLAST( d<20201001);
上次开仓量:=if(holding<>0,abs(holding),n1);
if CONDBUY and 日期条件 then SELLSHORT(1,HOLDING,MARKET);
if NUMPROFIT(1)<0 and ( CONDBUY) then begin
loss1:=loss1+1;
END
if NUMPROFIT(1)/ENTERPRICE>0.005 and ( CONDBUY) then begin
loss1:=0;
END
if CONDBUY and 日期条件 then buy(1,2,MARKET);
if CONDSELL and 日期条件 then sell(1,HOLDING,MARKET) ;
if NUMPROFIT(1)<0 and (CONDSELL) then begin
loss1:=loss1+1;
END
if NUMPROFIT(1)/ENTERPRICE>0.005 and (CONDSELL ) then begin
loss1:=0;
END
if condsell and 日期条件 then BUYSHORT(1,2,MARKET);
if condbuy and 日期条件 then sellshort(1,HOLDING,MARKET) ;
盈利次数:win_num;
亏损次数:loss_num;
连续亏损2次:count(ref(loss1,1)=2 and loss1=0 ,回测开始时间);
连续亏损3次:count(ref(loss1,1)=3 and loss1=0 ,回测开始时间);
连续亏损4次:count(ref(loss1,1)=4 and loss1=0 ,回测开始时间);
此主题相关图片如下:1.png
此主题相关图片如下:2.png