N:=60;
K值:="kdj.K";
DD:=C=LLV(C,N);{60日最低点}
DDSJ:=BArslAST(REF(DD,1));{上一低点时间}
DDGJ:=REF(CLOSE,DDSJ+1)>CLOSE;{股价趋势}
kdZB:=REF(K值,DDSJ+1)
GD:=C=HHV(C,N);{60日最高点}
GDSJ:=BARSLAST(REF(GD,1));{上一高点时间}
GDGJ:=REF(CLOSE,GDSJ+1)
K顶背离:=GDGJ AND KGZB;
macd:="MacD.MACD";
MDZB:=REF(MACD,DDSJ+1)
MGZB:=REF(MACD,GDSJ+1)>MACD;
M顶背离:=GDGJ AND MGZB;
rsi:="RSI.RSI1";
RDZB:=REF(RSI,DDSJ+1)
RGZB:=REF(RSI,GDSJ+1)>RSI;
R顶背离:=GDGJ AND RGZB;
TYP:=(HIGH + LOW + CLOSE)/3;
cci:=(TYP-MA(TYP,N))/(0.015*AVEDEV(TYP,N));
CDZB:=REF(CCI,DDSJ+1)
C底背离:=DDGJ AND CDZB;
CGZB:=REF(CCI,GDSJ+1)>CCI;
C顶背离:=GDGJ AND CGZB;
REFLINE: -5,15,30,COLORBLACK;
DRAWTEXT(K顶背离,IF(ISLASTBAR,27.5,25),'◆'),LINETHICK2 ;
DRAWTEXT(M顶背离,(ISLASTBAR,24.5,20),'◆'),LINETHICK2 ;
DRAWTEXT(R顶背离,(ISLASTBAR,20.5,15.1),'◆'),LINETHICK2 ;
DRAWTEXT(C顶背离,(ISLASTBAR,16.6,10.1),'◆'),LINETHICK2 ;
DRAWTEXT(ISLASTBAR,10.1 ,'CCI '),LINETHICK2,COLORGREEN;
DRAWTEXT(C底背离,IF(ISLASTBAR,12,10.1 ),'◆'),LINETHICK2,COLORRED;
DRAWTEXT(ISLASTBAR,15,'RSI '),LINETHICK2,COLORRED;
DRAWTEXT(R底背离,IF(ISLASTBAR,8.5,15),'◆'),LINETHICK2,COLORRED;
DRAWTEXT(ISLASTBAR,20,'MACD '),LINETHICK2,COLORMAGENTA;
DRAWTEXT(M底背离,IF(ISLASTBAR,4.5,20),'◆'),LINETHICK2,COLORRED;
DRAWTEXT(ISLASTBAR,25,'KDJ '),LINETHICK2,COLORRED;
DRAWTEXT(K底背离,IF(ISLASTBAR,1.5,25),'◆'),LINETHICK2,COLORRED;