N:=10;
N2:=150;
LC:=REF(CLOSE,1);
rsi:=SMA(MAX(CLOSE-LC,0),N,1)/SMA(Abs(CLOSE-LC),N,1)*100;
AVR1:=DRAWLINE(RSI>=HHV(RSI,N),RSI,RSI<=LLV(RSI,N),RSI,0);
Avr2:DRAWLINE(RSI<=LLV(RSI,N),RSI,RSI>=HHV(RSI,N),RSI,0)DOTLINE;
AVR3:=RSI=AVR2;
AVR4:=RSI=AVR1;
AVR5:=RSI<=REF(RSI,1) AND RSI<=REFX(RSI,1);
AVR6:=RSI>REF(RSI,1);
SJ:=CURRBARSCOUNT;
波峰:=IF(REF(AVR1,1)=DRAWNULL,AVR1,DRAWNULL);
L1:=COUNT(波峰>0 AND REF(波峰,1)=DRAWNULL,0);
A1:=CONST(L1)-L1;
L2:=IF(A1<=3,波峰,DRAWNULL);
一峰:=IF(ISLASTBAR,FINDHIGH(L2,0,N2,1),DRAWNULL);
二峰:=IF(ISLASTBAR,FINDHIGH(L2,0,N2,2),DRAWNULL);
三峰:=IF(ISLASTBAR,FINDHIGH(L2,0,N2,3),DRAWNULL);
四峰:=IF(ISLASTBAR,FINDHIGH(L2,0,N2,4),DRAWNULL);
平均H:=(一峰+二峰+三峰+四峰)/4;
IF(A1<=3,CONST(平均H),DRAWNULL)COLORLICYAN;
DRAWNUMBER(ISLASTBAR,平均H,平均H);
波谷:=IF(REF(AVR2,1)=DRAWNULL,AVR2,DRAWNULL);
L3:=COUNT(波谷>0 AND REF(波谷,1)=DRAWNULL,0);
A2:=CONST(L3)-L3;
L4:IF(A2<=3,波谷,DRAWNULL);
一谷:=IF(ISLASTBAR,FINDHIGH(L4,0,N2,1),DRAWNULL);
二谷:=IF(ISLASTBAR,FINDHIGH(L4,0,N2,2),DRAWNULL);
三谷:=IF(ISLASTBAR,FINDHIGH(L4,0,N2,3),DRAWNULL);
四谷:=IF(ISLASTBAR,FINDHIGH(L4,0,N2,4),DRAWNULL);
平均L:=(一谷+二谷+三谷+四谷)/4;
IF(A2<=3,CONST(平均L),DRAWNULL)COLORLIMAGENTA;
DRAWNUMBER(ISLASTBAR,平均L,平均L);