Range & PivotPine Script v6

ta.max()Max

Returns the greater of two values. Note: This is a simple comparison, not a lookback function like ta.highest().

Syntax

Syntax
ta.max(source1, source2) → series float

Arguments

ParameterTypeDescription
source1series int/floatFirst value or series.
source2series int/floatSecond value or series.

Returns

The greater of the two values.

Remarks

Evaluates element-wise on each bar; unrelated to ta.highest() window extrema.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.max")
plot(ta.max(close, open), title="Greater of O/C")

Trading Applications

Compare two indicator values

Build custom indicator combinations

Create conditional calculations

Use in true range computation

Related Functions

Frequently Asked Questions

ta.max() returns the larger of two inputs bar by bar. It is a pairwise maximum, not a rolling maximum over history.

ta.highest() scans a lookback window for the maximum of one series. ta.max() only compares two provided values on the current bar.

They are equivalent for two numeric inputs in Pine v5+; ta.max exists in the ta namespace alongside other technical helpers.

Generate ta.max() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.max() and other built-in functions instantly.