Skip to content

Instantly share code, notes, and snippets.

@bongkook
Created March 18, 2020 08:29
Show Gist options
  • Save bongkook/06b02570d326ed2c473988d5512b6b79 to your computer and use it in GitHub Desktop.
Save bongkook/06b02570d326ed2c473988d5512b6b79 to your computer and use it in GitHub Desktop.
//@version=3
study(title="Relative Strength Index", shorttitle="StochRSI/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=fuchsia, linewidth =2, transp=0)
band1 = hline(70)
band0 = hline(30)
fill(band1, band0, color=purple, transp=95)
//@version=3
//study(title="Stochastic RSI", shorttitle="Stoch RSI")
smoothK = input(3, minval=1)
smoothD = input(3, minval=1)
lengthRSI = input(14, minval=1)
lengthStoch = input(14, minval=1)
srcsrsi = input(close, title="RSI Source")
rsi1 = rsi(srcsrsi, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
plot(k, color=blue, transp=0)
plot(d, color=orange, transp=0)
h0 = hline(80)
h1 = hline(20)
fill(h0, h1, color=purple, transp=95)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment