Returns the arctangent of a number, an angle in radians whose tangent is that number.
math.atan is the inverse of math.tan. Every real number has an arctangent, which lands between -math.pi / 2 and math.pi / 2.
Because it squeezes any number into a bounded range, it is a convenient way to compress a slope: math.atan(slope) is a bounded angle.
Syntax
math.atan(angle: simple int/float) -> simple float
math.atan(angle: input int/float) -> input float
math.atan(angle: const int/float) -> const float
math.atan(angle: series int/float) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| angle | const/ | required | Any number, the ratio of a rise to a run. The result is an angle in radians. |
Returns
const/input/simple/series float: the angle in radians.
Remarks
- To get the angle of a price slope in degrees, use
math.todegrees(math.atan(slope)).
Example
//@version=6
indicator("Slope angle")
slope = (ta.sma(close, 20) - ta.sma(close, 20)[5]) / ta.atr(14) / 5
plot(math.todegrees(math.atan(slope)), "Angle", color = color.purple)
hline(0)See also
Runs on Sidechair