Sidechair

ta.max()

Browse the reference

Returns the largest value source has taken from the first bar to the current one.

Try it in the editor

ta.max keeps a running maximum. It starts with the first value and only rises, ignoring na values.

Use it for the all-time high of a series on the loaded history, such as a peak equity or peak RSI.

Syntax

Pine Script
ta.max(source: series int/float) -> series float

Arguments

NameTypeDefaultDescription
sourceseries int/floatrequiredThe series whose highest value so far is kept. Later bars can only raise it.

Returns

series float: the maximum of source over all bars so far.

Remarks

  • The result depends on how many bars are loaded. For a fixed window use ta.highest.
  • Not to be confused with math.max, which compares its arguments on one bar.

Example

Pine ScriptDrawdown from the running highOpen in editor
//@version=6
indicator("Drawdown from high")
peak = ta.max(close)
plot((close / peak - 1) * 100, "Drawdown %", color = color.red, style = plot.style_area)

See also

Runs on Sidechair