PDC:=REF(C,1);
TR1:=MAX(H-L,MAX(H-PDC,PDC-L));
ATR:=MA(TR1,20);
绝对波幅:=ATR*DYNAINFO(209);
rdp:=ln(c/ref(c,1));
vr:=std(rdp,60)*100;
vrma:=ma(vr,120);
N:=tASSET*0.01/绝对波幅;
h20:=ref(hhv(h,20),1);
l20:=ref(llv(l,20),1);
t1:=c>h20;
t2:=c<l20;
n1:=ref(ATR,BARSLAST(t1 and ref(t1,1)=0));
n2:=ref(ATR,BARSLAST(t2 and ref(t2,1)=0));
c1:=ref(c,BARSLAST(t1 and ref(t1,1)=0));
c2:=ref(c,BARSLAST(t2 and ref(t2,1)=0));
kd:cross(c,h20);
pd:c<(c1-3*n1);
kk:=cross(l20,c);
pk:=c>(c2+3*n2);
if TBUYHOLDING(1)>0 and pd then tsell(pd,if(range(vrma,0.1,0.9),n*2,n),mkt);
if tsellholding(1)>0 and pk then tsellshort(pk,if(range(vrma,0.1,0.9),n*2,n),mkt);
if tbuyholding(1)=0 and kd then tbuy(kd,if(range(vrma,0.1,0.9),n*2,n),mkt);
if tsellholding(1)=0 and kk then tbuyshort(kk,if(range(vrma,0.1,0.9),n*2,n),mkt);
if tholding>0 and c<DYNAINFO(211)-n1 then tsell(pd,if(range(vrma,0.1,0.9),n*2,n),mkt);
if tholding<0 and c>DYNAINFO(211)+n2 then tsellshort(pk,if(range(vrma,0.1,0.9),n*2,n),mkt);{止损块在有持仓时运行}