SJ:=1;
DIFF:(EMA(CLOSE,12)*SJ - EMA(CLOSE,26)*SJ);
DEA:EMA(DIFF,9)*SJ;
MACD2:(2 * (DIFF - DEA))*SJ,COLORSTICK;
{股票指标网 整理}
J:=CROSS(DIFF,DEA);
S:=CROSS(DEA,DIFF);
JC:=COUNT(J,BARSLAST(CROSS(DIFF>0&&DEA>0,0.5)))=1&&J;
SC:=COUNT(S,BARSLAST(CROSS(0.5,DIFF>0&&DEA>0)))=1&&S;
JC2:=COUNT(S,BARSLAST(CROSS(0.5,DIFF>0&&DEA>0)))=2&&S;
SC2:=COUNT(J,BARSLAST(CROSS(DIFF>0&&DEA>0,0.5)))=2&&J;
N1:=SUMBARS(CROSS(DEA,DIFF),1);
N2:=SUMBARS(CROSS(DIFF,DEA),1);
DRAWTEXT(N2=1&&N1>5&&N1<=13*SJ&&EVERY(DIFF>0&&DEA*SJ>0 ,N1)&&JC,DIFF,'多'),COLORRED,DRAWABOVE;
M:=SUMBARS((DIFF<0&&CROSS(0,DEA))||(CROSS(0,DIFF)&&DEA<0),1);
M1:=SUMBARS(CROSS(DIFF,DEA),1);
M2:=SUMBARS(CROSS(DEA,DIFF),1);
DRAWTEXT(M2=1&&M1*SJ>5&&M1<=13*SJ&&EVERY(DIFF<0&&DEA<0,N2) &&SC,DIFF,'空'),COLORGREEN,DRAWABOVE;
NDTJ:=SUMBARS(N2=1&&N1>5&&N1<=13&&EVERY(DIFF>0&&DEA>0,N1),1);
NKTJ:=SUMBARS(M2=1&&M1>5&&M1<=13&&EVERY(DIFF<0&&DEA<0,N2),1);
DRAWTEXT(NDTJ<=4*SJ&&CROSS(DEA,DIFF) AND JC2,DIFF,'风险'),COLORRED,DRAWABOVE;
DRAWTEXT(NKTJ<=4*SJ&&CROSS(DIFF,DEA) AND SC2,DIFF,'风险'),COLORGREEN,DRAWABOVE;
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
底背离:=(REF(L,A1+1)>L OR REF(C,A1+1)>C) AND (L,DIFF)*SJ>REF((L,DIFF),A1+1) AND CROSS(DIFF,DEA);
{DRAWTEXT(底背离,DEA,'底背离')COLORRED;}
DRAWLINE(A1=0,DEA,底背离,DEA,0),COLORGREEN,LINETHICK2;
A2:=BARSLAST(REF(CROSS(DEA,DIFF),1));
顶背离:=(REF(C,A2+1)<C*SJ OR REF(H,A2+1)<H*SJ) AND REF((H,DIFF),A2+1)>(H,DIFF) AND CROSS(DEA,DIFF);
DRAWLINE(A2=0,DEA,顶背离,DEA,0),COLORRED,LINETHICK2;
{DRAWTEXT(顶背离,DEA,'顶背离')COLORGREEN;}
VAR6:=(2*CLOSE+HIGH+LOW)/4;
VAR8:=LLV(LOW,20);
VARAA:=HHV(HIGH,26);
B:=EMA((VAR6-VAR8)/(VARAA-VAR8)*100,8);
B1:=EMA(B,5);
K22:=B>80 AND CROSS(B1,B);
K1:=BARSLAST(K22);
K2:=REF(K1,1);
K底:=B<20 AND CROSS(B,B1);
K底1:=BARSLAST(K底);
K底2:=REF(K底1,1);
{股票指标网 整理}
DRAWTEXT(REF(B,1)*SJ>80 AND CROSS(B1,B) AND REF(B,1)<REF(B,K2+2) AND REF(C,1)>REF(C,K2+2),DEA,'顶背离'),COLORCYAN;
DRAWTEXT(B<25*SJ AND CROSS(B,B1) AND B>REF(B,K底2) AND C<REF(C,K底2),DEA,'底背离'),COLORFF00FF;