Buongiorno, vorrei apportare delle modifiche al mio indicatore di divergenze RSI.
Vorrei fosse possibile cambiare i vari colori che lo compongono e che si possa decidere se mostrare o meno a grafico le divergenze regular e hidden.
Soprattutto vorrei fosse possibile inserire un’allarme in modo tale da ricevere una notifica quando viene rilevata una divergenza.
Grazie in anticipo allego il codice dell’indicatore:
len=14 //RSI Length
src=close
lbr=5 //pivot lookback Right
lbl=5 //pivot lookback Left
rangeUpper=60 //Max lookback range
rangeLower=5 //Min lookback range
plotBull=1
plotHiddenBull=1
plotBear=1
plotHiddenBear=1
//———————————————-//
//—–RSI Calculation————————–//
//———————————————-//
osc=rsi[len](src)
midlevel=50
obLevel=70
osLevel=30
colorbetween(obLevel,osLevel,33,150,243,50)
//———————————————-//
//—–Pivots High and Low———————-//
//———————————————-//
//—Pivots low
if osc > osc[lbr] and lowest[lbr](osc) > osc[lbr] and osc[lbr] < lowest[lbl](osc)[lbr+1] then
$ply[z+1] = osc[lbr]
$plx[z+1] = barindex[lbr]
$pricel[z+1] = low[lbr]
drawpoint(barindex[lbr],osc[lbr],2)coloured(“red”,80)
z = z + 1
endif
//—Pivots high
if osc < osc[lbr] and highest[lbr](osc)<osc[lbr] and osc[lbr]>highest[lbl](osc)[lbr+1] then
$phy[t+1]=osc[lbr]
$phx[t+1]=barindex[lbr]
$priceH[t+1]=high[lbr]
drawpoint(barindex[lbr],osc[lbr],2)coloured(“blue”,80)
t=t+1
endif
//—Pivot detection
if z<>z[1] then
plFound=1
elsif t<>t[1] then
phFound=1
else
plFound=0
phFound=0
endif
barsPL=barssince(plFound[1])
inrangePL=rangelower<=barsPL and barsPL<=rangeupper
barsPH=barssince(pHFound[1])
inrangePH=rangelower<=barsPH and barsPH<=rangeupper
//———————————————-//
//—–Regular Bullish————————–//
//———————————————-//
oscHL=osc[lbr]>$ply[max(0,z–1)] and inrangePL
priceLL=low[lbr]<$pricel[max(0,z–1)]
bullCondAlert=priceLL and oscHL and plFound
bullCond=plotBull and bullCondalert
if plFound and bullCond then
drawsegment($plx[max(0,z–1)],$ply[max(0,z–1)],$plx[z],$ply[z])coloured(“green”)style(line,2)
endif
//———————————————-//
//—–Hidden Bullish—————————//
//———————————————-//
oscLL=osc[lbr]<$ply[max(0,z–1)] and inrangePL
priceHL=low[lbr]>$pricel[max(0,z–1)]
hiddenBullCondAlert=priceHL and oscLL and plFound
hiddenBullCond=hiddenBullCondAlert and plotHiddenBull
if plFound and hiddenBullCond then
drawsegment($plx[max(0,z–1)],$ply[max(0,z–1)],$plx[z],$ply[z])coloured(“green”,80)style(line,2)
endif
//———————————————-//
//—–Regular Bearish————————–//
//———————————————-//
oscLH=osc[lbr]<$phy[max(0,t–1)] and inrangePH
priceHH=high[lbr]>$priceH[max(0,t–1)]
bearCondAlert=priceHH and oscLH and pHFound
bearCond=plotBear and bearCondalert
if pHFound and bearCond then
drawsegment($phx[max(0,t–1)],$phy[max(0,t–1)],$phx[t],$phy[t])coloured(“red”)style(line,2)
endif
//———————————————-//
//—–Hidden Bearish—————————//
//———————————————-//
oscHH=osc[lbr]>$phy[max(0,t–1)] and inrangePH
priceLH=high[lbr]<$priceh[max(0,t–1)]
hiddenBearCondAlert=priceLH and oscHH and phFound
hiddenBearCond=hiddenBearCondAlert and plotHiddenBear
if pHFound and hiddenBearCond then
drawsegment($phx[max(0,t–1)],$phy[max(0,t–1)],$phx[t],$phy[t])coloured(“red”,80)style(line,2)
endif
//———————————————-//
return osc as “RSI”coloured(“blue”)style(line,2), midlevel as “MidLevel”coloured(“grey”)style(dottedline,1),obLevel as “obLevel”coloured(“grey”)style(dottedline,1),osLevel as “osLevel”coloured(“grey”)style(dottedline,1)