Skip to main content

Overview

The math namespace mirrors the JavaScript Math object with Pine Script-compatible names. All functions are available globally as math.*.

Arithmetic

Min / max

Rounding

Trigonometric

Constants

The math namespace does not expose math.PI directly - use the literal 3.14159265358979 or derive it from math.asin(1) * 2 if needed.

Random

math.random() is available but its output changes on every indicator re-evaluation. Avoid using it for anything that should produce stable chart output.

str.*

String utilities namespace.

NaN handling

math.* functions propagate NaN - guard inputs with nz().