从 pine 脚本中获得的随机值与交易视图中的实际值不匹配

Stochastic value obtained from pine script not matching with actual value in tradingview

我正在尝试使用 pine 脚本在交易视图中绘制随机 (14,1,1)。但是如果我使用交易视图的指标工具绘制随机指标,输出是 different.I 我使用的代码如下:

//@version=4
study("My Script")
Length = input (14, minval=1, title = "Stochastic Length")
k = input (1, minval=1, title = "Stochastic %K")
d = input (1, minval=1, title = "Stochastic %D")
Sto = stoch (close, highest(Length), lowest(Length), Length)
K= sma (Sto, k)
D= sma (Sto, d)
plot (D, title  ="%D", color = color.red, linewidth=1)
plot (K, title  ="%K", color = color.aqua, linewidth=1)
hline(80, title = "Upper Limit", color = color.red, linestyle =  hline.style_dotted)
hline(20, title = "Lower Limit", color = color.lime, linestyle =  hline.style_dotted)

Screenshot of stochastics in tradingview

区别可以在上面的截图中看出。

如果我做错了什么,请帮助更正代码。

需要使用:

Sto = stoch (close, high, low, Length)

而不是:

Sto = stoch (close, highest(Length), lowest(Length), Length)