Skip to content

Instantly share code, notes, and snippets.

Created January 11, 2018 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save anonymous/4bbe60943697fdd0b3f59786ece9e343 to your computer and use it in GitHub Desktop.
Save anonymous/4bbe60943697fdd0b3f59786ece9e343 to your computer and use it in GitHub Desktop.
slightly improved version of indicator with Stochastic RSI and RSI with alerts from autemox
// ver 1 alerts show significant stoch rsi crossovers as long as they arent in outermost bounds
// ver 2 fixed error with > to >= that caused some alerts to not appear
// ver 3 changed from symbols to columns to make it easier to set up real trading view alerts with it!
// BASED on https://www.tradingview.com/script/aUZVp1GC-Stochastic-RSI-with-Crossover-Alerts/
// Author: autemox
study(title="Stochastic RSI with Crossover Alerts", shorttitle="Stoch RSI with Crossover Alerts")
smoothK = input(3, minval=1)
smoothD = input(3, minval=1)
lengthRSI = input(14, minval=1)
lengthStoch = input(14, minval=1)
src = input(close, title="RSI Source")
rsi1 = rsi(src, lengthRSI)
rsih0 = hline(70, title='RSI Up line')
rsih1 = hline(30, title='RSI Down line')
fill(rsih0, rsih1, color=purple, transp=80, title='RSI Background')
plot(rsi1, color=purple, title="RSI")
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
plot(k, color=blue, title="K")
plot(d, color=orange, title="D")
h0 = hline(80, title='Stochastic Up Line')
h1 = hline(20, title='Stochastic Down Line')
fill(h0, h1, color=purple, transp=80, title='Stochastic Background')
linecol = k[0] >= d[0] and k[1] <= d[1] and k <= 60 and k >= 5 ? green : white
linecol2 = k[0] <= d[0] and k[1] >= d[1] and k >= 40 and k <= 95 ? red : linecol
data = (60-k[1])/2
data2 = (k[1]-40)/2
plot(k[1] >= d[1] and k[2] <= d[2] and k <= 60 and k >= 10 ? data : na , style=columns,color=green,title="Cross Up Confirmed") // show a green column higher if stoch is deeper
plot(k[1] <= d[1] and k[2] >= d[2] and k >= 40 and k <= 95 ? data2 : na , style=columns,color=red, title="Cross Down Confirmed") // show a red column higher if stoch is higher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment