Sidechair

ta.highest()

Browse the reference

Returns the highest value of source over the last length bars, including the current one.

Try it in the editor

ta.highest scans the window of length values and returns the largest. With a single argument, ta.highest(length), the source is the bar high.

Until length bars have printed the result is na, and an na inside the window also gives na.

Syntax

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

Arguments

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

Returns

series float: the largest value in the window, or na while it is not full.

Remarks

  • Compare the current bar against ta.highest(high, n)[1] to test for a breakout of the previous n bars.

Example

Pine ScriptDonchian upper channelOpen in editor
//@version=6
indicator("Highest high", overlay = true)
len = input.int(20, "Length", minval = 1)
plot(ta.highest(high, len), "Highest high", color = color.green)
plot(ta.lowest(low, len), "Lowest low", color = color.red)

See also

Runs on Sidechair