N:=9;
M:=3;
LOWV:=LLV(LOW,N);
HIGHV:=HHV(HIGH,N);
RSV:=EMA((CLOSE-LOWV)/(HIGHV-LOWV)*100,M);
K:EMA(RSV,M);
D:MA(K,M);
J:3*K-2*D;
A:80;
B:20;
DRAWICON(crOSS(K,D),D,1);
DRAWICON(CROSS(D,K),D,2);
A1:=BArslAST(REF(CROSS(K,D),1));
底背离:REF(CLOSE,A1+1)>CLOSE AND K>REF(K,A1+1) AND CROSS(K,D);
DRAWLINE(A1=0,D,底背离,D,0),colorred,LINETHICK1;
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,LINETHICK1;
DRAWTEXT(底背离>0,D-5,'买'),colorred;
DRAWTEXT(顶背离>0,D-5,'跑'),colorgreen;
高位谨慎减仓:80;
低位留意加仓:20;
SHORT:=12;LONG:=26;MID:=9;
DIF:=100*(EMA(CLOSE,SHORT)-EMA(CLOSE,LONG));
DEA:=EMA(DIF,MID);
macd:=(DIF-DEA)*2;
X1_1:=55;
X1_2:=34;
X1_3:=100*(HHV(HIGH,X1_1)-CLOSE)/(HHV(HIGH,X1_1)-LLV(LOW,X1_1));
X1_4:=(CLOSE-LLV(LOW,X1_2))/(HHV(HIGH,X1_2)-LLV(LOW,X1_2))*100;
X1_5:=vol/((HIGH-LOW)*2-Abs(CLOSE-OPEN));
X1_6:=SMA(X1_4,3,1);
X1_7:=SMA(X1_6,3,1);
X1_8:=3*X1_6-2*X1_7;
X1_9:=EMA(X1_8,6);
擒妖:CROSS(X1_9,X1_3) AND X1_9<50,colorred;