if barstate.islast
// Loop through the last 1000 bars
for i = 0 to 1000
float _pivotHigh = na
int _leftBars = 10
int _rightBars = 10
int _pivotRange = ( _leftBars + _rightBars )
float _leftEdgeValue = nz(_series[_pivotRange], na)
if not na(_series) and _leftBars > 0 and _rightBars > 0 and not na(_leftEdgeValue)
float _possiblePivotHigh = _series[_rightBars]
float[] _arrayOfSeriesValues = array.new_float(0)
for _barIndex = _pivotRange to 0
array.push(_arrayOfSeriesValues, _series[_barIndex])
//end for
int _pivotHighRightBars = array.size(_arrayOfSeriesValues) - array.lastindexof(_arrayOfSeriesValues, array.max(_arrayOfSeriesValues)) - 1
_pivotHigh := ( _pivotHighRightBars == _rightBars ) ? _possiblePivotHigh : na
// Plot the label when a pivot point is detected. (Nothing gets plotted)
if not na(_pivotHigh)
label.new(bar_index[_leftBars], _pivotHigh, text=str.tostring(_pivotHigh))
当我们到达图表的末尾时,将实施一个回顾循环以遍历最后 1000 个柱,并且需要绘制和标记该时期的枢轴点。目前,没有任何计划。