Docs

math.sign

Reduce a series to -1, 0 or 1 by its sign, for example to read the direction of a move.

itm
math.sign(x)

-1, 0 or 1 by the sign of the value.

Parameters

A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.

NameKindTypeDefaultRangeDescription
xSeriesnumber--The value to transform.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
None.
Missing values
na in, na out. A result outside the finite range is a calculation error.

Example

itm
math.sign(close)
itm
plot(math.sign(ta.change(close, 1)), "Direction")