Docs

math.atan2

Take the angle of a slope from its two components, in the correct quadrant.

itm
math.atan2(y, x)

Arc tangent of y/x in radians, in (-pi, pi], using the signs of both arguments to pick the quadrant. Use it when you take an angle from a slope. math.atan2(0, 0) is 0, the convention standard libraries use.

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
ySeriesnumber--The vertical component.
xSeriesnumber--The horizontal component.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
None.
Missing values
na in either argument gives na.

Example

itm
math.atan2(ta.change(close, 1), 1)
itm
plot(math.atan2(ta.change(close, 1), 1), "Slope angle")