思路:以均线相交的情况作为分笔顶点的依据。(是否有道理,还需检验!)
同时以价格乘以时间间隔的开方作为动能。以此作为依据,与前笔比较判定是否背驰。有背驰为细线,无背驰为粗线。
该指标是飞狐指标,简单修改后可以在通达信和东财上使用。但无法在大智慧上使用,因为使用了反向过滤filterx函数。
MD6:MA(C,3);
MD5:MA(C,8);
MD4:MA(C,21);
MD3:MA(C,55);
MD2:MA(C,144);
MD1:MA(C,377);
L1:=IF(MD2>=MD1,1,0);
L2:=IF(MD3>MD2 OR MD3=MD2 AND L1=0,1,0);
L3:=IF(MD4>MD3 OR MD4=MD3 AND L2=0,1,0);
L4:=IF(MD5>MD4 OR MD5=MD4 AND L3=0,1,0);
L5:=IF(MD6>MD5 OR MD6=MD5 AND L4=0,1,0);
L6:=IF(C>MD6 OR C=MD6 AND L5=0,1,0);
LL1:=L1+L2*2+L3*4;
LL2:=L4+L5*2+L6*4;
GG:=IF(LL2=7 OR LL2=3,H,0.5*L);
GD:=IF(LL2=0 OR LL2=4,L,1.5*H);
均线顶0:=(LL2=7 OR LL2=3 AND (REF(LL2,1)=7 OR REF(LL2,1)=3) AND (H>REF(H,1) )) ;
均线底0:=(LL2=0 OR LL2=4 AND (REF(LL2,1)=0 OR REF(LL2,1)=4) AND (L<REF(L,1))) ;
GG2:=IF(均线顶0,H,0.9*H);
GD2:=IF(均线底0,L,1.1*L);
均线顶A:=FILTERX(均线顶0 AND GG2=HHV(GG2,BARSLAST(均线底0)),BARSLAST(均线底0));
均线底A:=FILTERX(均线底0 AND GD2=LLV(GD2,BARSLAST(均线顶0)),BARSLAST(均线顶0));
修正顶:=均线顶A;
修正底:=均线底A;
最后底:=filterx(修正底,100000);
x1:=if(修正底,barslast(修正顶),if(修正顶,barslast(修正底),0));
erea:=if(修正底,sqrt(x1)*(ref(h,x1)-l),if(修正顶,(h-ref(l,x1))*sqrt(x1),0));
y1:=ref(x1,x1)+x1;
erea2:=ref(erea,y1);
v1:=if(修正底 or 修正顶, sum(v,x1)/10000,0);
v2:=ref(v1,y1);
e2:=ref(erea,y1);
vv1:=v2/e2*erea;
drawnumber(修正底 ,l*0.97,v1,2),coloryellow;
drawnumber(修正底 ,l*0.98,erea,2),colorred;
drawnumber(修正底 ,l*0.99,l,2),colorgreen;
drawnumber(最后底 ,l*0.96,vv1,2),COLORMAGENTA;
drawnumber( 修正顶,h*1.03,v1,2),coloryellow;
drawnumber( 修正顶,h*1.02,erea,2),colorred;
drawnumber( 修正顶,h*1.01,h,2),COLORMAGENTA;
DRAWLINE(修正底,LOW,修正顶 and erea > erea2, HIGH,0),COLORMAGENTA,LINETHICK3;
DRAWLINE(修正底,LOW,修正顶 and erea <= erea2 , HIGH,0),COLORMAGENTA,LINETHICK1;
DRAWLINE(修正顶,HIGH,修正底 and erea > erea2 , LOW,0),COLORGREEN,LINETHICK3;
DRAWLINE(修正顶,HIGH,修正底 and erea <= erea2 , LOW,0),COLORGREEN,LINETHICK1;
再上传一个通达信可用直接使用的源码。
MD6:MA(C,3);
MD5:MA(C,8);
MD4:MA(C,21);
MD3:MA(C,55);
MD2:MA(C,144);
MD1:MA(C,377);
L1:=IF(MD2>=MD1,1,0);
L2:=IF(MD3>MD2 OR (MD3=MD2 AND L1=0),1,0);
L3:=IF(MD4>MD3 OR (MD4=MD3 AND L2=0),1,0);
L4:=IF(MD5>MD4 OR (MD5=MD4 AND L3=0),1,0);
L5:=IF(MD6>MD5 OR (MD6=MD5 AND L4=0),1,0);
L6:=IF(C>MD6 OR (C=MD6 AND L5=0),1,0);
LL1:=L1+L2*2+L3*4;
LL2:=L4+L5*2+L6*4;
GG:=IF(LL2=7 OR LL2=3,H,0.5*L);
GD:=IF(LL2=0 OR LL2=4,L,1.5*H);
均线顶0:=LL2=7 OR (LL2=3 AND (REF(LL2,1)=7 OR REF(LL2,1)=3) AND (H>REF(H,1) )) ;
均线底0:=LL2=0 OR (LL2=4 AND (REF(LL2,1)=0 OR REF(LL2,1)=4) AND (L<REF(L,1))) ;
GG2:=IF(均线顶0,H,0.9*H);
GD2:=IF(均线底0,L,1.1*L);
均线顶A:=FILTERX(均线顶0 AND GG2=HHV(GG2,BARSLAST(均线底0)),BARSLAST(均线底0));
均线底A:=FILTERX(均线底0 AND GD2=LLV(GD2,BARSLAST(均线顶0)),BARSLAST(均线顶0));
均线顶:=FILTERX(均线顶A AND GG2=HHV(GG2,BARSLAST(均线底A)),BARSLAST(均线底A));
均线底:=FILTERX(均线底A AND GD2=LLV(GD2,BARSLAST(均线顶A)),BARSLAST(均线顶A));
顶高:=REF(H,BARSLAST(均线顶));
底底:=REF(L,BARSLAST(均线底));
{
修正顶A:=均线顶 OR ((LL2=1 OR LL2=3 OR LL2=5) AND BARSLAST(均线顶)<BARSLAST(均线底) AND H=HHV(H,BARSLAST(均线顶)+1));
修正底A:= 均线底 OR ((LL2=2 OR LL2=4 OR LL2=6) AND BARSLAST(均线底)<BARSLAST(均线顶) AND L=LLV(L,BARSLAST(均线底)+1));
GG3:=IF(修正顶A,H,0.9*H);
GD3:=IF(修正底A,L,1.1*L);
修正顶:=FILTERX(修正顶A AND GG3=HHV(GG3,BARSLAST(修正底A)),BARSLAST(修正底A));
修正底:=FILTERX(修正底A AND GD2=LLV(GD3,BARSLAST(修正顶A)),BARSLAST(修正顶A));}
修正顶:=均线顶;
修正底:=均线底;
X1:=IF(修正底,BARSLAST(修正顶),IF(修正顶,BARSLAST(修正底),0));
EREA:=IF(修正底,SQRT(X1)*(REF(H,X1)-L),IF(修正顶,(H-REF(L,X1))*SQRT(X1),0));
Y1:=REF(X1,X1)+X1;
EREA2:=REF(EREA,Y1);
V1:=IF(修正底 OR 修正顶, SUM(V,X1)/10000,0);
DRAWNUMBER(修正底 ,L*0.97,V1),COLORYELLOW;
DRAWNUMBER(修正底 ,L*0.98,EREA),COLORRED;
DRAWTEXT(修正底 ,L*0.99,CON2STR(L,2)),COLORGREEN;
DRAWNUMBER( 修正顶,H*1.03,V1),COLORYELLOW;
DRAWNUMBER( 修正顶,H*1.02,EREA),COLORRED;
DRAWTEXT( 修正顶,H*1.01,CON2STR(H,2)),COLORLIRED;
DRAWLINE(修正底,LOW,修正顶 AND EREA > EREA2, HIGH,0),COLORMAGENTA,LINETHICK3;
DRAWLINE(修正底,LOW,修正顶 AND EREA <= EREA2 , HIGH,0),COLORMAGENTA,LINETHICK1;
DRAWLINE(修正顶,HIGH,修正底 AND EREA > EREA2 , LOW,0),COLORGREEN,LINETHICK3;
DRAWLINE(修正顶,HIGH,修正底 AND EREA <= EREA2 , LOW,0),COLORGREEN,LINETHICK1;