{Zen in trouble·A must-have for all friends - MACD divergence indicator}
DIFF:EMA(CLOSE,12)-EMA(CLOSE,27);
p>
DEA:EMA(DIFF,9);
MACD:2*(DIFF-DEA), COLORSTICK,LINETHICK2;
Low Golden Cross:=CROSS(DIFF ,DEA) AND DIFF<-0.1;
STICKLINE(Low Golden Cross,0,0.08,6,0),COLORYELLOW;
DRAWTEXT(Low Golden Cross,0.16,' Low Golden Cross'),COLORWHITE;
JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
Second Golden Cross:=CROSS( DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;
STICKLINE(quadratic golden cross,0,0.06,6,0),COLORFF00FF;
< p>DRAWICON(Secondary Golden Cross,DEA*0.9,1);DRAWTEXT(Secondary Golden Cross,0.2,' Quadratic Golden Cross'),COLORYELLOW;
A1 :=BARSLAST(REF(CROSS(DIFF,DEA),1));
Bottom divergence:=REF(CLOSE,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND CROSS(DIFF,DEA);
STICKLINE(Divergence,0,0.03,6,0),COLOR00FF00;
Backline:DRAWLINE(A1=0,DEA,Divergence ,DEA,0),COLORRED,LINETHICK4;
DRAWTEXT(bottom divergence,0.12,'bottom divergence'),COLORFF00FF;
A2:=BARSLAST(REF(CROSS(DEA, DIFF),1));
Top divergence:=REF(CLOSE,A2+1)
Top and back: DRAWLINE(A2=0,DEA,top divergence,DEA,0),COLORGREEN,LINETHICK4;
DRAWTEXT(low golden cross AND secondary golden cross AND bottom divergence, 0.25, 'Three full terms'),COLOR0000FF,LINETHICK2;
The long-standing formula indicator {Personal opinion, for reference only.
}