如何编写随机RSI指标

时间:2019-04-27 19:37:42

标签: indicator pine-script tradingview-api

我的指标看起来与交易视图中的随机RSI指标不一样。公式看起来如何,从而使st-RSI指标倍增?

Herer是screen shot,显示了我的代码和tradingview指标之间的区别

//@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)

曲线应与交易视图指标相同

1 个答案:

答案 0 :(得分:0)

此公式应如下所示:

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)