///////////////////////////////////////////////////////////
ONCE NumberOfBars = 40
ONCE WRperiods = 14
ONCE Distance = 25 * pipsize
//
ONCE NumberOfBars = max(1,min(999,NumberOfBars))
ONCE WRperiods = max(1,min(999,WRperiods))
ONCE Distance = Distance * PipSize
//
r = 255
g = 0
b = 0
t = 255
//
src = CustomClose
//
hh = highest[WRperiods](high)
ll = lowest[WRperiods](low)
WR = ((hh-src)/(hh-ll))*-100
//
IF (BarIndex > (WRperiods + NumberOfBars)) THEN
// Divergenza Ribassista
IF (WR[1] > WR) AND (WR[1] > WR[2]) THEN
extremum2=WR[1]
extremum1=highest[NumberOfBars](WR)
Prezzomax2=src[1]
Prezzomax=Highest[NumberOfBars](src)
IF(extremum2 < extremum1) AND (Prezzomax2 > Prezzomax[1]) THEN
FOR i = 1 TO NumberOfBars
if WR[i] = extremum1 then
zz = i
drawsegment (barindex[1], WR[1]+Distance, barindex[zz], WR[zz]+Distance) coloured(r,g,b,t)
endif
next
endif
endif
// Divergenza Rialzista
IF (WR[1] < WR) AND (WR[1]<WR[2]) THEN
extremum22 = WR[1]
extremum11 = lowest[NumberOfBars](WR)
Prezzomin2 = src[1]
Prezzomin = lowest[NumberOfBars](src)
IF(extremum22 > extremum11) AND (Prezzomin2 < Prezzomin[1]) THEN
FOR i2 = 1 TO NumberOfBars
if WR[i2] = extremum11[1] then
zz2 = i2
r = 0
g = 0
b = 255
drawsegment(barindex[1], WR[1]-Distance, barindex[zz2], WR[zz2]-Distance) coloured(r,g,b,t)
endif
next
ENDIF
ENDIF
endif
return WR as "Willimas R%"//, 0 as "0"