N:=10;
DIF:MA(CLOSE,10)-MA(CLOSE,50);
AMA:MA(DIF,10);
B:=DIF-REF(DIF,1);
IF(B>=0,DIF,DRAWNULL),COLORRED,LINETHICK2;
IF(B<=0,DIF,DRAWNULL),COLORFF9900,LINETHICK2;
rsi1:=DIF;
AA:=REF(RSI1,N)=HHV(RSI1,2*N+1);
BB:=BacKSET(AA,N+1);
CC:=FILTER(BB,N) AND RSI1=HHV(RSI1,N+1);
A1:=BArslAST(REF(CC,1));
顶背离:=REF(CLOSE,A1+1)
DRAWLINE(CC,RSI1,FILTER(顶背离>0,5),RSI1,0),COLORGREEN;
AA2:=REF(RSI1,N)=LLV(RSI1,2*N+1);
BB2:=BACKSET(AA2,N+1);
CC2:=FILTER(BB2,N) AND RSI1=LLV(RSI1,N+1);
A2:=BARSLAST(REF(CC2,1));
底背离:=REF(CLOSE,A2+1)>CLOSE AND REF(RSI1,A2+1)