TradingView 图表上的水平线

Horizontal line on chart on TradingView

我在 TradingView 上使用图表,我想画水平线。 水平线是枢轴点。

我计算了它们,每个值都存储在一个变量中。

width = input(2, minval=1)
xHigh  = security(tickerid,"D", high[1])
xLow   = security(tickerid,"D", low[1])
xClose = security(tickerid,"D", close[1])
vPP = (xHigh+xLow+xClose) / 3
vR1 = vPP+(vPP-xLow)
vS1 = vPP-(xHigh - vPP)
vR2 = vPP + (xHigh - xLow)
vS2 = vPP - (xHigh - xLow)
vR3 = xHigh + 2 * (vPP - xLow) 
vS3 = xLow - 2 * (xHigh - vPP)

我试过用这条线来完成这项工作

plot(vPP, color=black, title="vPP", style = line, linewidth = width)

但是一天到一天,这条线并没有切断。所以它看起来不太好。看图片。

这就是我要找的结果:

我愿意:

感谢您的建议

尝试 style = plot.style_linebr 而不是 style = line 或者

style = linebr

要删除连接线,您必须在值更改时使用颜色na
有关代码示例,请参阅 PineCoders-LucF to one of my questions

的答案

编辑:您的代码示例已修改为按预期工作。

//@version=4
study("My Script", overlay=true)

width = input(2, minval=1)
xHigh  = security(syminfo.ticker,"D", high[1])
xLow   = security(syminfo.ticker,"D", low[1])
xClose = security(syminfo.ticker,"D", close[1])

vPP = (xHigh+xLow+xClose) / 3
vR1 = vPP+(vPP-xLow)
vS1 = vPP-(xHigh - vPP)
vR2 = vPP + (xHigh - xLow)
vS2 = vPP - (xHigh - xLow)
vR3 = xHigh + 2 * (vPP - xLow) 
vS3 = xLow - 2 * (xHigh - vPP)

plot(vPP, color=change(vPP) ? na : color.black, title="vPP", style = plot.style_linebr, linewidth = width)

根据评论中的要求,@version=3 的代码。
备注:您真的应该使用@version=4 来访问最新的Pine 脚本功能。

//@version=3
study("My Script", overlay=true)

width = input(2, minval=1)
xHigh  = security(tickerid,"D", high[1])
xLow   = security(tickerid,"D", low[1])
xClose = security(tickerid,"D", close[1])

vPP = (xHigh+xLow+xClose) / 3
vR1 = vPP+(vPP-xLow)
vS1 = vPP-(xHigh - vPP)
vR2 = vPP + (xHigh - xLow)
vS2 = vPP - (xHigh - xLow)
vR3 = xHigh + 2 * (vPP - xLow) 
vS3 = xLow - 2 * (xHigh - vPP)

plot(vPP, color=change(vPP) ? na : black, title="vPP", style = linebr, linewidth = width)