问题描述
我想获取上一次枢轴高点的柱线索引,因此我可以用它来绘制从该索引开始的指标,但似乎无法使其正常工作。
/var/lib/clamav/daily.cld: Can't allocate memory ERROR
如果有人能告诉我如何将发生支点的所有索引保存为数组,以便我可以访问它们,那也很好。例如,定义了一个枢轴数组,如果我执行ivot [0],它将返回15(例如),它对应于最新枢轴的条形索引。
解决方法
您可以使用内置的barssince
函数,并在历史记录引用运算符[]
中使用结果
barssincePhigh = barssince(phigh)
barssincePlow = barssince(plow)
但是,默认情况下,您的枢轴会在10个小节之后触发,请将leftbars
值添加到平衡结果中以显示高/低枢轴:
//@version=4
study("Pivot Prices",overlay=true)
leftbars = input(10,minval=1,title='Bars to the left')
rightbars = input(10,title='Bars to the right')
phigh = pivothigh(high,leftbars,rightbars)
plow = pivotlow(low,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)