Sidechair

ta.lowestbars()

Browse the reference

Returns how many bars back the lowest value of source in the last length bars occurred, as 0 or a negative number.

Try it in the editor

ta.lowestbars returns 0 when the lowest value in the window is on the current bar, -1 when it was one bar ago, and so on to -(length - 1). On a tie, the most recent bar is chosen.

With a single argument, ta.lowestbars(length), the source is low. Output begins when length bars are in the window.

Syntax

Pine Script
ta.lowestbars(source: series int/float, length: series int) -> series int

Arguments

NameTypeDefaultDescription
sourceseries int/floatrequiredSeries to scan. Leave it out, passing only the length, to scan low.
lengthseries intrequiredNumber of bars in the window. A whole number of 1 or more.

Returns

series int: the bar offset of the window's lowest value: 0 for the current bar, negative for earlier ones.

Remarks

  • A result of 0 means the current bar sets the window low.

Example

Pine ScriptAge of the 30-bar lowOpen in editor
//@version=6
indicator("Age of low")
age = -ta.lowestbars(low, 30)
plot(age, "Bars since 30-bar low", color = color.blue, style = plot.style_stepline)

See also

Runs on Sidechair