繁体   English   中英

随机 RSI 上的 Plotshape -(Pine 脚本初学者)

[英]Plotshape on Stochastic RSI - (Pine script beginner)

我正在尝试在 Stockastic RSI ( K ) 上使用 plotshape 函数以附加(打开)并随 K 线移动。 但是代码有问题,绘图远离 K 线(顶部或底部)。 我想让它和K线一起炒股。

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

Cross1 = k<20
Cross2 = k>80
plotshape(Cross1 , "dots", style=shape.circle, location = location.bottom )
plotshape(Cross2 , "dots", style=shape.circle, location = location.top )

在此处输入图像描述

您正在使用location = location.bottomlocation = location.top ,这就是原因。

您应该使用location = location.absolute然后将k作为您的series值。

plotshape(Cross1 ? k : na, "dots", style=shape.circle, location = location.absolute)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM