The indicator gives a dot in the indicator window when the rsi k line crosses up the 70 or down the 30 into overbought or oversold.
——————————————————————————————–
//@version=3
study(“Stochastic RSI”, shorttitle=”Stoch RSI Crossovers”, overlay=false)
/////////////////////////////////////////////////
///// Variables and Inputs /////
/////////////////////////////////////////////////
// Define The Variables //
V = volume
O = open
H = high
L = low
C = close
srcSelect = input(title = “Select the Stochastic RSI Source”, defval = “Close”, options=[“Open”, “High”, “Low”, “Close”, “Volume”, “HL/2”, “HLC/3”, “OHLC/4″])
src = iff(srcSelect==”Open”, O, iff(srcSelect==”High”, H, iff(srcSelect==”Low”, L, iff(srcSelect==”HL/2″, hl2, iff(srcSelect==”HLC/3″, hlc3, iff(srcSelect==”OHLC/4″, ohlc4, iff(srcSelect==”Volume”, V, C)))))))
len = input(title = “Select the Stochastic RSI Length”, defval = 14, minval = 1, step = 1)
stochK = input(title = “Select the %K Time Period (Orange)”, defval = 3, minval = 1, step = 1)
stochD = input(title = “Select the %D Time Period (Blue)”, defval = 3, minval = 1, step = 1)
checkOBPlot = input(title = “Plot the Overbought Crosses?”, defval = true)
overSold = input(title = “Select the Overbought Level”, defval = 80, minval = 1, step = 1)
checkOSPlot = input(title = “Plot the Oversold Crosses?”, defval = false)
overBought = input(title = “Select the Oversold Level”, defval = 20, minval = 1, step = 1)
/////////////////////////////////////////////////
///// Stochastic RSI Calc /////
/////////////////////////////////////////////////
sRSI = rsi(src, len)
k = sma(stoch(sRSI, sRSI, sRSI, len), stochK)
d = sma(k, stochD)
/////////////////////////////////////////////
///// Plots and Plot Conditions /////
/////////////////////////////////////////////
plot(k, title=”Stochastic RSI K% Line”, color = orange, style = line, linewidth=1)
plot(d, title=”Stochastic RSI D% Line”, color = blue, style = line, linewidth=1)
oSoldLine = hline(overSold, title=’Oversold’, color=gray, linestyle=dotted, linewidth=1)
oBoughtLine = hline(overBought, title=’Overbought’, color=gray, linestyle=dotted, linewidth=1)
fill(oSoldLine, oBoughtLine, color=gray, transp=80)
kCrossOver = crossover(k, overSold)
dCrossOver = crossover(d, overSold)
kCrossUnder = crossunder(k, overBought)
dCrossUnder = crossunder(d, overBought)
plotshape(checkOBPlot and kCrossOver ? k : na, title=”K% Overbought”, color=green, style=shape.circle, location=location.absolute, size=size.tiny, transp=50)
plotshape(checkOBPlot and dCrossOver ? d : na, title=”D% Overbought”, color=red, style=shape.circle, location=location.absolute, size=size.tiny, transp=50)
plotshape(checkOSPlot and kCrossUnder ? k : na, title=”K% Oversold”, color=green, style=shape.circle, location=location.absolute, size=size.tiny, transp=50)
plotshape(checkOSPlot and dCrossUnder ? d : na, title=”D% Oversold”, color=red, style=shape.circle, location=location.absolute, size=size.tiny, transp=50)
alertcondition(kCrossOver, title=”K% Overbought Alert”, message=”K% Crossed Into Overbought”)
alertcondition(dCrossOver, title=”D% Overbought Alert”, message=”D% Crossed Into Overbought”)
alertcondition(kCrossOver, title=”K% Oversold Alert”, message=”K% Crossed Into Oversold”)
alertcondition(dCrossOver, title=”D% Oversold Alert”, message=”D% Crossed Into Oversold”)