[英]Pine script: plotting horizontal lines at every pivothigh/pivotlow value
我正在尝试在每个 pivothigh/pivotlow 值处 plot 一条水平线(在两个方向上延伸)。 我快到了,但我被困在最后一点。 有人可以帮我吗? 这只是一个虚拟代码,仅使用ta.pivothigh()
来显示我卡在哪里。
//@version=5
indicator(title="test", shorttitle="test", overlay=true)
pivotLength = 100
highOffset = high[pivotLength]
pivotHigh = ta.pivothigh(high, pivotLength, pivotLength)
yValues = ta.valuewhen(not na(pivotHigh), highOffset, 0)
line levelLine = line.new(bar_index, yValues, bar_index - 1, yValues, extend = extend.both) // <= getting stuck here
不幸的是,我只是重复绘制最后一条水平线( levelLine
)。 我不知道如何 plot 之前的水平线(是的,我知道如果有很多 pivot 值,由于 Pine Script 的限制,并非所有水平线都会显示)。
我想到了:
//@version=5
indicator(title="test", shorttitle="test", overlay=true)
pivotLength = 100
highOffset = high[pivotLength]
if ta.pivothigh(high, pivotLength, pivotLength)
line.new(bar_index, highOffset , bar_index - 1, highOffset , extend = extend.both, color = color.red)
//@version=5
indicator(title="test", shorttitle="test", overlay=true)
pivotLength = 100
highOffset = ta.pivothigh(high, pivotLength, pivotLength)
if not(na(highOffset))
line levelLine = line.new(bar_index, highOffset, bar_index - 1, highOffset, extend = extend.both, color = color.red)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.