![](/img/trans.png)
[英]How pivothigh() and pivotlow() function work on Tradingview Pinescript?
[英]pinescript get index of pivothigh
我想获取最后一次出现 pivothigh 的条形索引,以便我可以将它用于 plot 一个从该索引开始的指标。 对pinescript不熟悉,参考文献有限
您可以使用内置的barssince
function 并在历史参考运算符[]
中使用结果
barssincePhigh = barssince(phigh)
barssincePlow = barssince(plow)
但是,默认情况下,您的枢轴在 10 个柱后触发,将leftbars
值添加到 barsisnce 结果以显示高/低 pivot:
//@version=4
study("Pivot Prices", overlay=true)
leftbars = input(10, minval=1, title='Bars to the left')
rightbars = input(10, minval=1, title='Bars to the right')
phigh = pivothigh(high, leftbars, rightbars)
plow = pivotlow(low, leftbars, rightbars)
barssincePhigh = barssince(phigh) + leftbars
barssincePlow = barssince(plow) + leftbars
if phigh
label1 = label.new(bar_index[barssincePhigh], high[barssincePhigh], text=tostring(high[barssincePhigh]), style = label.style_labeldown, color = color.orange)
if plow
label2 = label.new(bar_index[barssincePlow], low[barssincePlow], text=tostring(low[barssincePlow]), style = label.style_labelup, color = color.green)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.