Nabi Shaikh
Nabi Shaikh

Reputation: 851

using label.new lookback candle count for Stoch-Rsi 20 CrossOver/Crossunder for 20/80 levels

I am trying you create a label.new for stochastic-Rsi indicator which specify no of candles back crossover or crossunder occured . The label.new text should consist of below text

Label should have content as shown

//@version=5
indicator(title="Stochastic RSI", shorttitle="Stoch RSI", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
smoothK = input.int(3, "K", minval=1)
smoothD = input.int(3, "D", minval=1)
lengthRSI = input.int(14, "RSI Length", minval=1)
lengthStoch = input.int(14, "Stochastic Length", minval=1)
src = input(close, title="RSI Source")
rsi1 = ta.rsi(src, lengthRSI)
k = ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = ta.sma(k, smoothD)
plot(k, "K", color=#2962FF)
plot(d, "D", color=#FF6D00)
h0 = hline(80, "Upper Band", color=#787B86)
hline(50, "Middle Band", color=color.new(#787B86, 50))
h1 = hline(20, "Lower Band", color=#787B86)
fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")

Expected Output in Image is as Follows.

Indicator should look like as in image

Upvotes: 0

Views: 46

Answers (0)

Related Questions