PeriodeRSI = 10
hausse = (MAX(0, CLOSE - CLOSE[1])) + (MAX(0, OPEN - OPEN[1]))
baisse = (MAX(0, CLOSE[1] - CLOSE)) + (MAX(0, OPEN[1] - OPEN))
mmHausse = WILDERAVERAGE[PeriodeRSI](hausse)
mmBaisse = WILDERAVERAGE[20](baisse)
RS = mmHausse - mmBaisse
monRSI = 100 - 100 / (1 + RS)
x = monRSI
Surachat = 80
Survente = 20
// DIVERGENCES BAISSIERES RSI
if x>Surachat then
hi=max(hi,x)
hico=max(hico,max(high,high[1]))
endif
if x crosses under Surachat then
sto2b=sto1b
sto1b=hi
hi=0
p3b=p1b
p2b=max(p1b,hico1)
p1b=max(highest[30](high),hico)
if p2b=p1b then
p2b=max(p3b,p4b)
endif
hico=0
hico1=0
endif
if x<Surachat then
p4b=hico1
hico1=max(hico1,high)
endif
if p1b>p2b and sto1b<sto2b and x crosses under Surachat and x<x[1] then
drawtext("V",barindex,high+0.00005,Dialog,Standard,20) coloured(0,255,0)
endif
// DIVERGENCES HAUSSIERES RSI
if x<Survente then
lo=min(lo,x)
lowco=min(lowco,min(low,low[1]))
endif
if x CROSSES OVER Survente then
sto2h=sto1h
sto1h=lo
lo=100
p3h=p1h
p2h=min(p1h,lowco1)
p1h=min(lowest[30](low),lowco)
if p2h=p1h then
p2h=min(p3h,p4h)
endif
lowco=100000
lowco1=100000
endif
if x>Survente then
p4h=lowco1
lowco1=min(lowco1,low)
endif
if p1h<p2h and sto1h > sto2h and x crosses over Survente and x>x[1] then
drawtext("A",barindex,low-0.00005,Dialog,Standard,20) coloured(0,255,0)
endif
RETURN