[PEL] 复制代码 variable:len1:=0,len2:=0;
ema30:ema(c,30),colorwhite;
ktxs:=ema30>ref(ema30,1) and ref(ema30,1)>ref(ema30,2);//拐头向上
ktxx:=ema30<ref(ema30,1) and ref(ema30,1)<ref(ema30,2);//拐头向下
if ktxs or (not(ktxs or ktxx) and len1<>0) then len1:=len1+1;//仅在红绿转换时候进行 拐头的切换,否则沿用最近的拐头方向,这样做是因为一个趋势中间个别突破的k会造成趋势断开。
if ktxx then len1:=0;
if ktxx or (not(ktxs or ktxx) and len2<>0) then len2:=len2+1;
if ktxs then len2:=0;
if ktxs or (not(ktxs or ktxx) and len1<>0) then red:ema30,colorred;
if ktxx or (not(ktxs or ktxx) and len2<>0) then green:ema30,colorgreen;
jc:cross(h,ema30);
sc:cross(ema30,l);
lenj:=barslast(jc);
lens:=barslast(sc);
hc:hhv(c,len1),nodraw;//多趋势最大的c
lc:llv(c,len2),nodraw;
if h>hc then dzy:sell(1,holding,market);
if l<lc then kzy:sellshort(1,holding,market);
if len2>0 then dzs:sell(1,holding,market);
if len1>0 then kzs:sellshort(1,holding,market);
if lens<len1 and lens>0 and len1>0 and isup and (typebar(1,1)>len1 or typebar(1,1)=-1) and c>ema30 then buy(holding=0,1,market);
if lenj<len2 and lenj>0 and len2>0 and isdown and (typebar(1,3)>len2 or typebar(1,3)=-1) and c<ema30 then buyshort(holding=0,1,market);
|