math.atan2
Take the angle of a slope from its two components, in the correct quadrant.
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.
| Name | Kind | Type | Default | Range | Description |
|---|---|---|---|---|---|
y | Series | number | - | - | The vertical component. |
x | Series | number | - | - | The horizontal component. |
Output
| Name | Type |
|---|---|
value | number |
Warm-up and missing values
- Warm-up
- None.
- Missing values
- na in either argument gives na.
Example
math.atan2(ta.change(close, 1), 1)plot(math.atan2(ta.change(close, 1), 1), "Slope angle")