DIFF : EMA(CLOSE,12) - EMA(CLOSE,26) LINETHICK2;
DEA : EMA(DIFF,9);
MACD := 2*(DIFF-DEA);
STICKLINE(MACD>0 AND MACD>=REF(MACD,1),0,MACD,0.2,0),COLOR0000FF;
STICKLINE(MACD>0 AND MACD<REF(MACD,1),0,MACD,0.2,0),COLORFFFF00;
STICKLINE(MACD<0 AND MACD>=REF(MACD,1),0,MACD,0.2,0),COLORFF00FF;
STICKLINE(MACD<0 AND MACD<REF(MACD,1),0,MACD,0.2,0),COLOR00FF00;
DD1:=L>=REF(L,1) AND REF(L,1)<=REF(L,2) AND REF(L,1)=LLV(L,20);
DD2:=backset(DD1,10)=0;
DD:=DD2 and ref(DD1,1);
TT:=BARSLAST(REF(DD,1));
底背离1:=DD AND REF(L,2)<REF(L,TT+3) AND REF(DIFF,2)>REF(DIFF,TT+3);
DRAWICON(底背离1,DIFF*1.1,13);
DRAWICON(DD,DIFF,12);
DRAWTEXT(底背离1,DIFF*1.2,'底背离'),colorred;
GD1:=H<=REF(H,1) AND REF(H,1)>=REF(H,2) AND REF(H,1)=HHV(H,20);
GD2:=backset(GD1,10)=0;
GD:=GD2 and ref(GD1,1);
GT:=BARSLAST(REF(GD,1));
顶背离1:=GD AND REF(H,2)>REF(H,GT+3) AND REF(DIFF,2)<REF(DIFF,GT+3);
DRAWICON(顶背离1,DIFF*0.8,12);
DRAWICON(GD,DIFF,13);
DRAWTEXT(顶背离1,DIFF*1.2,'顶背离'),colorgreen;
底背离:(DD AND REF(L,2)<REF(L,TT+3) AND REF(DIFF,2)>REF(DIFF,TT+3))*0.1;
顶背离:(GD AND REF(H,2)>REF(H,GT+3) AND REF(DIFF,2)<REF(DIFF,GT+3))*0.1;