Skip to content

Instantly share code, notes, and snippets.

@comerc
Last active January 31, 2021 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save comerc/5ccb888cc187d8c4d0b3057804ff8070 to your computer and use it in GitHub Desktop.
Save comerc/5ccb888cc187d8c4d0b3057804ff8070 to your computer and use it in GitHub Desktop.
RSI / STOCH RSI OVERLAY for TradingView
study(title="RSI / STOCH RSI OVERLAY by AndrewKa", shorttitle="STOCH V RSI")
src = close, len = input(14, minval=1, title="Length")
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(rsi, color=#B5CA92, linewidth=1, transp=20)
band1 = hline(70, linestyle=solid)
band0 = hline(30, linestyle=solid)
fill(band1, band0, transp=100)
smoothK = input(3, minval=1)
smoothD = input(3, minval=1)
lengthRSI = input(14, minval=1)
lengthStoch = input(14, minval=1)
src1 = input(close, title="RSI Source")
rsi1 = rsi(src, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
plot(k, color=#0094FF)
plot(d, color=#FF6A00)
h0 = hline(80)
h1 = hline(20)
fill(h0, h1, transp=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment