gpt4 book ai didi

pine-script - pinescript 获取 pivothigh 的索引

转载 作者:行者123 更新时间:2023-12-04 15:20:43 27 4
gpt4 key购买 nike

我想获取最后一次出现 pivothigh 的柱线索引,以便我可以使用它来绘制从该索引开始的指标。对pinescript不熟悉,引用文献有限

最佳答案

您可以使用内置的 barssince函数并使用历史引用运算符中的结果[]

barssincePhigh = barssince(phigh)
barssincePlow = barssince(plow)
但是默认情况下您的枢轴在 10 根柱线后触发,添加 leftbars barsisnce 结果的值以显示高/低枢轴:
//@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)

关于pine-script - pinescript 获取 pivothigh 的索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63367231/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com