OPEN-SOURCE SCRIPT

Stochastic RSI with Custom Level

123
//version=6
indicator("Stochastic RSI with Custom Level", overlay = false)

// Input parameters
rsiLength = input.int(14, title="RSI Length")
stochLength = input.int(14, title="Stochastic Length")
kSmooth = input.int(3, title="K Smoothing")
dSmooth = input.int(3, title="D Smoothing")
customLevel = input.float(80, title="Custom Level for True/False Output")
timeframe = input.timeframe("2D", title="Timeframe")

// Calculate RSI
rsi = ta.rsi(close, rsiLength)

// Calculate Stochastic RSI
stochRsi = ta.stoch(rsi, rsi, rsi, stochLength)
k = ta.sma(stochRsi, kSmooth)
d = ta.sma(k, dSmooth)

// Plot Stochastic RSI
plot(k, title="Stochastic RSI %K", color=color.blue)
plot(d, title="Stochastic RSI %D", color=color.red)

// True/False output based on custom level
output = k > customLevel
plotshape(output, title="Output", location=location.top, color=color.green, style=shape.labelup, text="True")

// Screener functionality
if (output)
label.new(bar_index, high, "Selected", color=color.green, textcolor=color.white, style=label.style_label_up)

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.