Z:=9;N:=5;
VAR4:=ZIG(3,Z);
RSV:=(VAR4-LLV(VAR4,N))/(HHV(VAR4,N)-LLV(VAR4,N))*100;
K: SMA(RSV,3,1),ColorFFFFFF;
D: SMA(K,3,1),Color00FFFF;
J: 3*K-2*D,ColorFF00FF;
V1:=TROUGHBARS(3,Z,1);
V2:=PEAKBARS(3,Z,1);
V3:=BARSLAST(V1>=V2);
V4:=BARSLAST(V2>=V1);
V11:=TROUGH(3,Z,1);
V12:=(CLOSE-V11)/V11*100>Z AND REF(CLOSE,2) <= REF(CLOSE,1) AND CLOSE < REF(CLOSE,1) AND REF(CLOSE,1)=HHV(CLOSE,V3);
V21:=PEAK(3,Z,1);
V22:=(V21-CLOSE)/V21*100>Z AND REF(CLOSE,2)>=REF(CLOSE,1) AND CLOSE>REF(CLOSE,1) AND REF(CLOSE,1)=LLV(CLOSE,V4);
V31:=V1=1 or V22;
V32:=V2=1 or V12;
ZF: IF(V4>0,((CLOSE-HHV(CLOSE,V4))/(HHV(CLOSE,V4)))*(100),((CLOSE-LLV(CLOSE,V3))/(CLOSE))*(100)),ColorFFFF00,ColorStick;