月K:"kdj.K"(89,3,3),NODRAW,COLORCYAN;
月D:"kdJ.D"(89,3,3),COLORCYAN,LINETHICK1;
周K:"KDJ.K"(27,3,3),NODRAW,COLORRED;
周D:"KDJ.D"(27,3,3),COLORRED,LINETHICK1;
日K:"KD.K"(5,3,3),NODRAW,COLORYELLOW;
日D:"KD.D"(5,3,3),COLORYELLOW,LINETHICK1;
日金叉:=crOSS(日K,日D);
周金叉:=CROSS(周K,周D);
月金叉:=CROSS(月K,月D);
X1:=日D>REF(日D,1);
DRAWICON(X1,日D*0.98,36);
X2:=日D
DRAWICON(X2,日D*0.98,37);
X3:=周D>REF(周D,1);
DRAWICON(X3,周D*0.98,36);
X4:=周D
DRAWICON(X4,周D*0.98,37);
X5:=月D>REF(月D,1);
DRAWICON(X5,月D*0.98,36);
X6:=月D
DRAWICON(X6,月D*0.98,37);
DRAWICON(日金叉,日D*0.98,25);
DRAWICON(CROSS(周D,日D),周D*0.98,27);
DRAWICON(周金叉,周D*0.98,34);
DRAWICON(CROSS(月D,周D),月D*0.98,35);
DRAWICON(月金叉,月D*0.98,13);
DRAWICON(CROSS(月D,日D),月D*0.98,14);
二叉共振:=日金叉+周金叉+月金叉=2;
三叉共振:=日金叉+周金叉+月金叉=3;
STICKLINE(二叉共振,35,65,1,0),COLORRED;
STICKLINE(二叉共振,40,60,1,-1),COLORCYAN;
STICKLINE(三叉共振,30,70,1,0),COLORRED;
STICKLINE(三叉共振,36,64,1,-1),COLORYELLOW;
DRAWTEXT(二叉共振,55,'二金叉共振');
DRAWTEXT(三叉共振,55,'三金叉共振');
DRAWTEXT(CURRBARSCOUNT=25,70,'编辑优化'),COLOR555555;
{KD在30以下多次金叉}
JM:=CROSS("KDJ.K"(5,3,3),"KDJ.D"(5,3,3));
JMCOUNT:=COUNT(JM,BArslAST("KDJ.D"(5,3,3)>=30));
JMTJ:=28*("KDJ.D"(5,3,3)<30 AND COUNT(JMCOUNT=1,21)=1);
DRAWTEXT (JMTJ,70,'①'),COLORWHITE;
JMTJ2:=28*("KDJ.D"(5,3,3)<30 AND COUNT(JMCOUNT=2,21)=1);
DRAWTEXT (JMTJ2,70,'②'),COLORYELLOW;
JMTJ3:=28*("KDJ.D"(5,3,3)<30 AND COUNT(JMCOUNT=3,21)=1);
DRAWTEXT (JMTJ3,70,'③'),COLORYELLOW;
JMTJ4:=28*("KDJ.D"(5,3,3)<30 AND COUNT(JMCOUNT=4,21)=1);
DRAWTEXT (JMTJ4,70,'④'),COLORYELLOW;
JMTJ5:=28*("KDJ.D"(5,3,3)<30 AND COUNT(JMCOUNT=5,21)=1);
DRAWTEXT (JMTJ5,70,'⑤'),COLORYELLOW;
DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
macd:=2*(DIFF-DEA);
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
B1:=REF(C,A1+1)>C AND REF(DIFF,A1+1)
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:=SMA(RSV,3,1);
D:=SMA(K,3,1);
A2:=BARSLAST(REF(CROSS(K,D),1));
B2:=REF(C,A2+1)>C AND REF(K,A2+1)
LC:=REF(CLOSE,1);
rsi1:=SMA(MAX(CLOSE-LC,0),6,1)/SMA(Abs(CLOSE-LC),6,1)*100;
RSI2:=SMA(MAX(CLOSE-LC,0),12,1)/SMA(ABS(CLOSE-LC),12,1)*100;
A3:=BARSLAST(REF(CROSS(RSI1,RSI2),1));
B3:=REF(C,A3+1)>C AND REF(RSI1,A3+1)
C1:=BARSLAST(REF(CROSS(DEA,DIFF),1));
D1:=REF(C,C1+1)
MACD顶背离:STICKLINE(FILTER(D1>0,5),-10,0,3,1),COLOR0066FF;
C2:=BARSLAST(REF(CROSS(D,K),1));
D2:=REF(C,C2+1)
KDJ顶背离:STICKLINE(FILTER(D2>0,5),-10,0,3,1),COLORRED;
C3:=BARSLAST(REF(CROSS(RSI2,RSI1),1));
D3:=REF(C,C3+1)
RSI顶背离:STICKLINE(FILTER(D3>0,5),-10,0,3,1),COLORFF00FF;
DRAWTEXT(FILTER(D3>0,5),0,'--R顶背离'),COLORFF00FF;
DRAWTEXT(FILTER(D2>0,5),-10,'--K顶背离'),COLORRED;
DRAWTEXT(FILTER(D1>0,5),-5,'--M顶背离'),COLOR0066FF;
DRAWTEXT(FILTER(B3>0,5),-10,'--R底背离'),COLORWHITE;
DRAWTEXT(FILTER(B2>0,5),-20,'--K底背离'),COLORYELLOW;
DRAWTEXT(FILTER(B1>0,5),-15,'--M底背离'),COLORGREEN;