Sidechair

math.acos()

Browse the reference

Returns the arccosine of a number, an angle in radians whose cosine is that number.

Try it in the editor

math.acos is the inverse of math.cos. It accepts values from -1 to 1 and returns an angle from 0 to math.pi.

A value outside -1 to 1 has no angle, and the result is na.

Syntax

Pine Script
math.acos(angle: simple int/float) -> simple float
math.acos(angle: input int/float) -> input float
math.acos(angle: const int/float) -> const float
math.acos(angle: series int/float) -> series float

Arguments

NameTypeDefaultDescription
angleconst/input/simple/series int/floatrequiredA value from -1 to 1. Anything outside that range gives na.

Returns

const/input/simple/series float: the angle in radians.

Remarks

  • math.acos(1) is 0 and math.acos(-1) is math.pi.

Example

Pine ScriptArccosine of a scaled seriesOpen in editor
//@version=6
indicator("Arccosine")
x = ta.stoch(close, high, low, 14) / 50 - 1
plot(math.todegrees(math.acos(x)), "Angle (degrees)", color = color.orange)

See also

Runs on Sidechair