RicardoSantos

[RS]RSI Divergence Candles V2

Update: added midline, changed some OB/OS lines color.
Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?
study(title="[RS]RSI Divergence Candles V2")
useHL = input(title='Use high/low series for mapping the wicks?', type=bool, defval=false)
src = input(title='Source Series:', type=source, defval=close)
fast_length = input(title='Fast Length:', type=integer, defval=8)
slow_length = input(title='Slow Length:', type=integer, defval=55)
smooth = input(title='Smooth:', type=integer, defval=10)
overbought = input(title='Overbought Level:', type=float, defval=70)
oversold = input(title='Oversold Level:', type=float, defval=30)

fast_rsi = rsi(src, fast_length)
slow_rsi = rsi(src, slow_length)

smooth_fast_rsi = sma(fast_rsi, smooth)
smooth_slow_rsi = sma(slow_rsi, smooth)

rsi_high = useHL ? max(rsi(high, fast_length), rsi(high, slow_length)) : max(fast_rsi, slow_rsi)
rsi_low = useHL ? min(rsi(low, fast_length), rsi(low, slow_length)) : min(fast_rsi, slow_rsi)
//#9ce0b2//#e0b29c
isBull=smooth_fast_rsi>=smooth_slow_rsi
isExp=abs(smooth_fast_rsi-smooth_slow_rsi)>=abs(smooth_fast_rsi[1]-smooth_slow_rsi[1])
plotcandle(smooth_slow_rsi, rsi_high, rsi_low, smooth_fast_rsi, title='rsi bars', color=isBull and isExp?green:isBull and not isExp?#9ce0b2:not isBull and isExp?maroon:#e0b29c)

hline(100, color=black)
hline(overbought, color=maroon)
hline(50, color=gray)
hline(oversold, color=green)
hline(0, color=black)