Docs

ta.highestbars

Count how many bars ago the highest value of the window was set.

itm
ta.highestbars(source, length, min=length)

Bars since the highest value in the window: 0 on the bar that set it, up to length-1. The count is never negative.

Parameters

A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.

NameKindTypeDefaultRangeDescription
sourceSeriesnumber--The series to read.
lengthConstantnumber-1 to 10000Window in observed bars.
minConstantnumber-1 to 10000Valid values the window must hold before it reports (an option, written min=15). An na is skipped. Absent = length: the window must be full and gap-free.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
length bars. Names in the warm-up are this operator’s parameters.
Missing values
Returns na until length consecutive non-na observations are in the window. An na resets the accumulation. With min=, an na is skipped and the extreme is found among the valid observations once there are at least min of them. The count is in bars back from the current bar, na slots included.

Example

itm
ta.highestbars(high, 20)
itm
plot(ta.highestbars(high, 20), "Bars since high")