TradingView图表上的水平线

时间:2020-11-07 15:47:24

标签: pivot pine-script horizontal-line

我在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)

但是从一天到另一天,这条线没有中断。所以看起来不太好。看图片。 enter image description here

这是我正在寻找的结果:

enter image description here

我想要:

  • 显示今天和昨天的关键点。
  • 从今天开始直到会议结束
  • 在各行前面写下“ PP,S1 / S2 / S3,R1 / R2 / R3”

感谢您的建议

2 个答案:

答案 0 :(得分:1)

要删除连接线,必须在值更改时使用颜色na
有关代码示例,请参见PineCoders-LucF对我的一个问题Plotting manual levels for daily high,low,close

的回答

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

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

答案 1 :(得分:0)

尝试用style = plot.style_linebr代替style = line

style = linebr