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

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.