同花顺我的分笔公式
缠论分笔,未完成版,不断改进中,缠论分笔,未完成版,不断改进中
MID : MA(CLOSE,13),colorwhite;
UPPER: MID + 2*STD(CLOSE,13),colorligray;
LOWER: MID - 2*STD(CLOSE,13),colorligray;
//定义新的高与低
H1:H;
L1:L;
//定义与前一K线的关系:1-上涨,-1-下跌,0-包含
K=IF(H1>REF(H1,1) AND L1>REF(L1,1),1,IF(H1<REF(H1,1) AND L1<REF(L1,1),-1,0));
//标记包含关系
K0=IF(k=0,1,0);
//重置k0的计数
k0_no=0;
//包含处理
IF (K=0)
{
k0_no=REF(k0_no,1)+1;
H1:IF(REF(K,1)=1,HHV(H1,2),IF(REF(K,1)=-1,LLV(H1,2),H1));
L1:IF(REF(K,1)=1,HHV(L1,2),IF(REF(K,1)=-1,LLV(L1,2),L1));
K=REF(k,1);
}
//dd:1-顶分型,-1-底分型,0-非分型
dd:=IF(REF(K,1)=1 AND K=-1,1,IF(REF(K,1)=-1 AND K=1,-1,0));
STICKLINE(dd=1 OR dd =-1,HIGH,LOW,2),colorred;
//定义分型强度
//分型第一个K线的振幅
FZ=ABS(REF(H1,2+REF(k0_no,1))-REF(L1,2+REF(k0_no,1)));
IF(dd=1)
tops=0.6*((L1-REF(l1,2+REF(k0_no,1)))/fz)+0.4*((C-REF(l1,2+REF(k0_no,1)))/fz);
ELSE IF(dd=-1)
bottoms=0.6*((h1-REF(h1,2+REF(k0_no,1)))/fz)+0.4*((C-REF(h1,2+REF(k0_no,1)))/fz);
STICKLINE(tops<0.55 OR bottoms>-0.45,HIGH,LOW,3,),colorwhite;
//第一类底
bottom1=IF(dd=-1 AND BARSLAST(dd=1)>REF(k0_no,1)+3,1,0);
//第二类底
bottom2=IF(dd=-1 AND BARSLAST(dd=1)<=REF(k0_no,1)+3 AND REF(l1,1)<REF(l1,BARSLAST(dd=-1,1)+1),1,0);
//第一类顶
top1:=IF(dd=1 AND BARSLAST(dd=-1)>REF(k0_no,1)+3,1,0);
//第二类顶
top2:=IF(dd=1 AND BARSLAST(dd=-1)<=REF(k0_no,1)+3 AND REF(h1,1)>REF(h1,BARSLAST(dd=1,1)+1),1,0);
dd1=IF(top1 OR top2,1,IF(bottom1 OR bottom2,-1,0));
//二次循环
//第一类底
bottom3:=IF(dd1=-1 AND BARSLAST(dd1=1)>REF(k0_no,1)+3,1,0);
//第二类底
bottom4:=IF(dd1=-1 AND BARSLAST(dd1=1)<=REF(k0_no,1)+3 AND REF(l1,1)<REF(l1,BARSLAST(dd1=-1,1)+1),1,0);
//第一类顶
top3:=IF(dd1=1 AND BARSLAST(dd1=-1)>REF(k0_no,1)+3,1,0);
//第二类顶
top4:=IF(dd1=1 AND BARSLAST(dd1=-1)<=REF(k0_no,1)+3 AND REF(h1,1)>REF(h1,BARSLAST(dd1=1,1)+1),1,0);
dd2=IF(top1 OR top2,1,IF(bottom1 OR bottom2,-1,0));
//底与顶
bottom:= bottom3 OR bottom4;
top:= top3 OR top4;
//底延伸
bys=IF(bottom=1 AND BARSLAST(bottom=1,1)<BARSLAST(top=1),1,0);
//顶延伸
tys=IF(top=1 AND BARSLAST(top=1,1)<BARSLAST(bottom=1),1,0);
DRAWLINE(bottom=1,REF(L1,1),top=1,REF(H1,1),0),colorgreen,LINETHICK1;
DRAWLINE(top=1,REF(h1,1),bottom,REF(l1,1),0),colorgreen,LINETHICK1;
SELECT (dd=-1 AND bottoms>-0.5);