如何编写随机 RSI 指标

How to write a stochastic-RSI indikator

我的指标看起来不像 TradingView 的内置随机 RSI 指标。我怎样才能获得熟悉的外观,以复制 st-RSI 指标?

这是显示我的代码和 TradingView 指标之间差异的 screen shot

//@version=3
study("Stoch-RSI")
//smooth = (close + close[1] + close[2]) /3
smooth = close
p_k = stoch(rsi(smooth,14),high,low,14)
p_d = 0.0
for i = 1 to 3
    p_d := p_d + p_k[i]
p_d := p_d / 3

plot(p_k*30,color=orange)
plot(p_d*30,color=purple)
plot(close)

曲线看起来应该与交易视图指标相同

公式应该是这样的:

study(title="Stoch-RSI")
band1 = hline(20)
band0 = hline(80)
fill(band1, band0, color=purple,transp=90)
smoothK = input(3, minval=1)
smoothD = input(3, minval=1)
lengthRSI = input(14, minval=1)
lengthStoch = input(14, minval=1)
src4 = input(close, title="RSI Source")
rsi1 = rsi(src4, lengthRSI)
k = sma(stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK)
d = sma(k, smoothD)
plot(k, color=blue)
plot(d, color=red)
h0 = hline(80, linestyle=dotted)
h1 = hline(20, linestyle=dotted)