DIFF:EMA(CLOSE,9) - EMA(CLOSE,26),COLORWHITE;
DEA:EMA(DIFF,12),COLORYELLOW;
macd=2*(DIFF-DEA);
ZERO : 0;
GJ:=MAX(C,O);
L4:=LLV(GJ,4);
JL:=(HHV(DIFF,55)-LLV(DIFF,55))/5;
GT:=DEA>REF(DEA,1) AND REF(DEA,1)
A1:=BArslAST(REF(GT,1));
STICKLINE(MacD>0 AND MACD>=REF(MACD,1),0,MACD,2,0),COLOR0000FF;
STICKLINE(MACD>0 AND MACD
STICKLINE(MACD<0 AND MACD>=REF(MACD,1),0,MACD,2,0),COLORFF00FF;
STICKLINE(MACD<0 AND MACD
底背离:=REF(L4,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND GT;
DRAWLINE(A1=0,DEA,底背离,REF(DEA,A1),0),COLORRED,LINETHICK2;
DRAWLINE(底背离,DEA,底背离,REF(DEA,A1),0),COLORRED,LINETHICK2;
DRAWTEXT(底背离,REF(DEA,A1)*1.18,' 底背离'),COLORFF00FF;
H4:=HHV(GJ,4);
GT2:=DEAREF(DEA,2);
A2:=BARSLAST(REF(GT2,1));
顶背离:= REF(H4,A2+1)
DRAWLINE(A2=0 ,DEA,顶背离,REF(DEA,A2),0),COLORGREEN,LINETHICK2;
DRAWLINE(顶背离,DEA,顶背离,REF(DEA,A2),0),COLORGREEN,LINETHICK2;
DRAWTEXT(顶背离,REF(DEA,A2)*1.18,' 顶背离'),COLORGREEN;
死叉:=crOSS(DEA,DIFF);
DRAWICON(死叉,DIFF*0.95,'2');
N1:BARSLAST(死叉),NODRAW;
N2:REF(BARSLAST(死叉),N1+1),NODRAW;
N3:REF(BARSLAST(死叉),N2+N1+2),NODRAW;
CL1:=LLV(C,N1+1),NODRAW;
DIFL1:=LLV(DIFF,N1+1),NODRAW;
CL2:=REF(CL1,N1+1),NODRAW;
DIFL2:=REF(DIFL1,N1+1),NODRAW;
CL3:=REF(CL2,N1+1),NODRAW;
DIFL3:=REF(DIFL2,N1+1),NODRAW;
pdiFL2:=IF(DIFL2>0,INTPART(LOG(DIFL2))-1,INTPART(LOG(-DIFL2))-1);
mdiFL2:=INTPART(DIFL2/POW(10,PDIFL2));
PDIFL3:=IF(DIFL3>0,INTPART(LOG(DIFL3))-1,INTPART(LOG(-DIFL3))-1);
MDIFL3:=INTPART(DIFL3/POW(10,PDIFL3));
MDIFB2:=INTPART(DIFF/POW(10,PDIFL2));
MDIFB3:=INTPART(DIFF/POW(10,PDIFL3));
直接底背离:=(CL1
隔峰底背离:=(CL1
B:直接底背离 OR 隔峰底背离,NODRAW;
BG:((MDIFB2>REF(MDIFB2,1))*REF(直接底背离,1)) OR ((MDIFB3>REF(MDIFB3,1))*REF(隔峰底背离,1)),NODRAW;
底背离消失:=(REF(直接底背离,1) AND DIFL1<=DIFL2 ) OR (REF(隔峰底背离,1) AND DIFL1<=DIFL3);
STICKLINE(B OR BG,DIFF,DEA,8,0),COLORRED,LINETHICK2;
DRAWTEXT((B AND COUNT(B,2)=1),(DIFF*1.5),'钝'),COLORYELLOW;
DRAWTEXT(FILTER(BG,10),DIFF*1.5,'成'),COLORMAGENTA;
DRAWTEXT(FILTER(底背离消失,10),(DIFF+MACD),'失'),COLORGREEN;
STICKLINE(BG,0,DIFF+DEA,5,0),COLORRED,LINETHICK3;
金叉:=CROSS(DIFF,DEA);
DRAWICON(金叉,DIFF*0.95,'1');
M1:=BARSLAST(金叉),NODRAW;
M2:=REF(BARSLAST(金叉),M1+1);
M3:=REF(BARSLAST(金叉),M2+M1+2);
CH1:=HHV(C,M1+1),NODRAW;
DIFH1:=HHV(DIFF,M1+1),NODRAW;
CH2:=REF(CH1,M1+1),NODRAW;
DIFH2:=REF(DIFH1,M1+1),NODRAW;
CH3:=REF(CH2,M1+1),NODRAW;
DIFH3:=REF(DIFH2,M1+1),NODRAW;
PDIFH2:=IF(DIFH2>0,INTPART(LOG(DIFH2))-1,INTPART(LOG(-DIFH2))-1);
MDIFH2:=INTPART(DIFH2/POW(10,PDIFH2));
PDIFH3:=IF(DIFH3>0,INTPART(LOG(DIFH3))-1,INTPART(LOG(-DIFH3))-1);
MDIFH3:=INTPART(DIFH3/POW(10,PDIFH3));
MDIFT2:=INTPART(DIFF/POW(10,PDIFH2));
MDIFT3:=INTPART(DIFF/POW(10,PDIFH3));
直接顶背离:=(CH1>CH2 ) AND (MDIFT2
隔峰顶背离:=(CH1>CH3 AND CH3>CH2 ) AND (MDIFT3
T:=直接顶背离 OR 隔峰顶背离,NODRAW;
TG:=((MDIFT2
顶背离消失:=(REF(直接顶背离,1) AND DIFH1>=DIFH2 ) OR (REF(隔峰顶背离,1) AND DIFH1>=DIFH3);
STICKLINE(TG,0,DIFF+DEA,5,0), COLORGREEN,LINETHICK4;
STICKLINE(T OR TG,DIFF,DEA,8,0),COLORGREEN,LINETHICK2;
DRAWTEXT(FILTER(TG,20),DIFF*1.4,'成'),COLORMAGENTA;
DRAWTEXT(FILTER(顶背离消失,20),(DIFF+MACD),'失'),COLORGREEN;