DIF:EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:EMA(DIF,9),COLORYELLOW;
MACD:=(DIF-DEA)*2,COLORWHITE;
_MACD红柱_:IF(MACD>REF(MACD,1),MACD,DRAWNULL),
STICK,COLORRED,LINETHICK1;
_MACD绿柱_:IF(MACD<REF(MACD,1),MACD,DRAWNULL),
STICK,COLORGREEN,LINETHICK1;
低位金叉:=CROSS(DIF,DEA) AND DIF<-0.1;
JCCOUNT:=COUNT(CROSS(DIF,DEA),BARSLAST(DEA>=0));
二次金叉:=CROSS(DIF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;
A1:=BARSLAST(REF(CROSS(DIF,DEA),1));
底背离:=REF(CLOSE,A1+1)>CLOSE AND DIF>REF(DIF,A1+1) AND CROSS(DIF,DEA);
底背:DRAWLINE(A1=0,DEA,底背离,DEA,0),COLORRED,LINETHICK4;
{DRAWTEXT(底背离,0,' 底背离'),COLORFF00FF;}
A2:=BARSLAST(REF(CROSS(DEA,DIF),1));
顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(DIF,A2+1)>DIF AND CROSS(DEA,DIF);
顶背:DRAWLINE(A2=0,DEA,顶背离,DEA,0),COLORGREEN,LINETHICK4;
DRAWTEXT(低位金叉 AND 二次金叉 AND 底背离,0,'三全项'),COLOR0000FF,LINETHICK2;