LONG:=26;
SHORT:=12;
M:=9;N1:=6;N2:=12; N3:= 24; N:=3;
{DIFF:=(EMA(CLOSE,SHORT) - EMA(CLOSE,LONG))*100;}
DIFF:=IF(V!=INDEXV,(EMA(CLOSE,SHORT) - EMA(CLOSE,LONG))*100,
(EMA(CLOSE,SHORT) - EMA(CLOSE,LONG))*1);
DEA:=EMA(DIFF,M);
MACD:=3*(DIFF-DEA);
A:=HHV(DIFF,300);
B:=MACD-REF(MACD,1);
D1:=REF(MACD,1)-REF(MACD,2);
STICKLINE(MACD>0 AND B>0,0,MACD,1,0)COLORRED;
STICKLINE(MACD>0 AND B<0,0,MACD,1,0)COLORGRAY;
STICKLINE(MACD<0 AND B>0,0,MACD,1,0)COLORMAGENTA;
STICKLINE(MACD<0 AND B<0,0,MACD,1,0)COLORCYAN;
{KDJ}
RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
K:SMA(RSV,3,1),COLORWHITE;
D:SMA(K,3,1),COLORYELLOW;
J:3*K-2*D,COLORRED,LINETHICK2;
{东邪黄药师}
RSV1:EMA((C-LLV(LOW,13))/(HHV(HIGH,13)-LLV(LOW,13))*-100,3),COLORRED,LINETHICK2;
RSV2:EMA((C-LLV(LOW,21))/(HHV(HIGH,21)-LLV(LOW,21))*-100,3),COLORWHITE,LINETHICK2;
RSV3:EMA((C-LLV(LOW,89))/(HHV(HIGH,89)-LLV(LOW,89))*-100,3);
RSV4:EMA((C-LLV(LOW,55))/(HHV(HIGH,55)-LLV(LOW,55))*-100,3);
RSV5:EMA((C-LLV(LOW,120))/(HHV(HIGH,120)-LLV(LOW,120))*-100,3);
{KDJ反转}
火山:IF(J<=0,20,0),LINETHICK0;
STICKLINE(J<=0,90,100,8,0),COLORRED;
KDJ1:=REF(COUNT(J<REF(J,1),5)>=3,1) AND REF(J,1)<20;
KDJ2:=J>REF(J,1);
反转:IF(FILTER(KDJ1 AND KDJ2,3),50,0),COLORFFFF00;
VAR22:=REF(LOW,1);
VAR33:=SMA(ABS(LOW-VAR22),3,1)/SMA(MAX(LOW-VAR22,0),3,1)*100;
VAR44:=EMA(IF(CLOSE*1.3,VAR33*10,VAR33/10),3);
VAR55:=LLV(LOW,13);
VAR66:=HHV(VAR44,13);
VAR77:=IF(MA(CLOSE,34),1,0);
VAR888:=EMA(IF(LOW<=VAR55,(VAR44+VAR66*2)/2,0),3)/618*VAR77;
VAR999:=IF(VAR888>100,100,VAR888);
吸筹:VAR999,LINETHICK1,COLORCD7F32 ;
STICKLINE(VAR999>-120,0,VAR999,2,10),COLORFF00FF;
{KDJ背离金叉}
低位金:=CROSS(K,D) AND D<20;
STICKLINE(低位金,D,D+8,5,0),COLORYELLOW;
JCCOUNT:=COUNT(CROSS(K,D),BARSLAST(K>=D));
二次金:=CROSS(K,D) AND D<20 AND COUNT(JCCOUNT=2,34)=1;
STICKLINE(二次金,D,D+5,5,0),COLORFF80FF;
DRAWICON(二次金,D*0.85,1) ;
A1:=BARSLAST(REF(CROSS(K,D),1));
底背离:=REF(CLOSE,A1+1)>CLOSE AND K>REF(K,A1+1) AND CROSS(K,D);
STICKLINE(底背离,D,D+5,5,0),COLORRED;
DRAWLINE(A1=0,D,底背离,D,0),COLORRED,LINETHICK2;
DRAWTEXT(底背离>0,J,'底背离'),COLORRED;
A2:=BARSLAST(REF(CROSS(D,K),1));
顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(D,A2+1)>D AND CROSS(D,K);
DRAWLINE(A2=0,D,顶背离,D,0),COLORGREEN,LINETHICK2;
DRAWTEXT(顶背离>0,K+2,'顶背离'),COLORGREEN;
低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;
STICKLINE(低位金叉,0,0.08,6,0),COLORYELLOW;
DRAWTEXT(低位金叉,0.16,' 低位金叉'),COLORWHITE;
{JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));}
二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;
STICKLINE(二次金叉,0,0.06,6,0),COLORFF00FF;
DRAWICON(二次金叉,DEA*0.9,1) ;
DRAWTEXT(二次金叉,0.2,' 二次金叉'),COLORYELLOW;
STICKLINE(((MACD>REF(MACD,1)) AND (MACD>0)),0,MACD,1,0),COLORRED;
STICKLINE(((MACD<REF(MACD,1)) AND (MACD>0)),0,MACD,1,0),COLORGREEN;
DRAWTEXT(CROSS(K,D) AND CROSS(J,D), K,' ');
DRAWTEXT(CROSS(D,K) AND CROSS(K,J), D,' ');
DRAWICON(CROSS(D,K) AND CROSS(K,J),D+10,2);
{CCI背离}
DRAWTEXT(((LLV(LOW,21) = LOW) AND NOT((LLV(CCI,21) =CCI))),LLV(CCI,21)+150,'▲'),COLORRED;
DRAWTEXT(((HHV(HIGH,34) = HIGH) AND (MA(CCI,3)<REF(MA(CCI,3),1) OR
CCI<REF(CCI,1)) AND NOT((HHV(CCI,34) = CCI))),HHV(CCI,55)-150,'▼'),COLORGREEN;
{RSI逃顶抄底}
CROSS(83,RSI)*15,LINETHICK2,COLORBLUE;
CROSS(27,RSI)*15,LINETHICK2,COLORWHITE;
{MACD背离压力}
SQX:=(C-MA(CLOSE,13))*100;
低位金叉1:IF(CROSS(DIFF,DEA) AND DIFF<-0.1,15,DRAWNULL),COLORYELLOW,LINETHICK4,CROSSDOT;
JCCOUNT1:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
二次金叉1:IF(CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT1=2,21)=1,28,DRAWNULL),COLORFF00FF,LINETHICK4,CROSSDOT;
A11:=BARSLAST(REF(CROSS(DIFF,DEA),1));
底背离1:IF(REF(CLOSE,A11+1)>CLOSE AND DIFF>REF(DIFF,A11+1) AND CROSS(DIFF,DEA),40,DRAWNULL),COLORRED,LINETHICK4,CROSSDOT;
势: DRAWLINE(A11=0,DEA,底背离,DEA,0),COLORGREEN,LINETHICK3;{,COLORRED;}
A12:=BARSLAST(REF(CROSS(DEA,DIFF),1));
顶背离1:REF(CLOSE,A2+1)<CLOSE AND REF(DIFF,A2+1)>DIFF AND CROSS(DEA,DIFF),COLORWHITE;
顶背离_:=IF(REF(CLOSE,A2+1)<CLOSE AND REF(DIFF,A2+1)>DIFF AND CROSS(DEA,DIFF),66,DRAWNULL),COLORF08000,LINETHICK4,CROSSDOT;
压: DRAWLINE(A2=0,DEA,顶背离,DEA,0),COLORFFBB99,LINETHICK3;
A13:=CROSS(DIFF,DEA) AND DEA<0;
零下二次金叉1_:IF(FILTER(COUNT(A13,21)=2,10),53,DRAWNULL),COLORWHITE,LINETHICK4,CROSSDOT,LINETHICK3;
{短顶大顶}
VAR1:=((CLOSE-MA(CLOSE,6))/MA(CLOSE,6)*100+(CLOSE-MA(CLOSE,24))/MA(CLOSE,24)*100+(CLOSE-MA(CLOSE,32))/MA(CLOSE,32)*100)/3;
短顶:STICKLINE(VAR1>9 AND FILTER(VAR1<REF(VAR1,1),5),VAR1+2,0,3,0),COLORYELLOW;
大顶:STICKLINE(VAR1>20 AND FILTER(VAR1<REF(VAR1,1),5),VAR1+5,0,7,0),COLORWHITE;
LC := REF(CLOSE,1);
{庄拉线}
{AA:=EMA(C,2)-EMA(C,89);
AB:=(AA-EMA(AA,30))/C*20;
AC:=POW(AB,3)/2+POW(AB,2);
庄拉线:=IF(AC>0,AC,0),COLORMAGENTA,LINETHICK3;}
{波段介入}
F1:=REF(CLOSE,2);
F2:=SMA(MAX(CLOSE-F1,0),7,1)/SMA(ABS(CLOSE-F1),7,1)*100;
波段介入点:=IF(F2<19,19,0),COLORWHITE;