Sidechair

math.sin()

Browse the reference

Returns the sine of an angle given in radians.

Try it in the editor

math.sin takes an angle in radians and returns a value between -1 and 1. A full turn is 2 * math.pi radians.

Convert from degrees first with math.toradians. Sine waves make test signals and cycle indicators.

Syntax

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

Arguments

NameTypeDefaultDescription
angleconst/input/simple/series int/floatrequiredThe angle in radians, not degrees. Use math.toradians() to convert from degrees.

Returns

const/input/simple/series float: the sine, from -1 to 1.

Remarks

  • math.sin(0) is 0, and math.sin(math.pi / 2) is 1.

Example

Pine ScriptA cycle with period 20 barsOpen in editor
//@version=6
indicator("Sine wave")
plot(math.sin(2 * math.pi * bar_index / 20), "Sine", color = color.blue)
plot(math.cos(2 * math.pi * bar_index / 20), "Cosine", color = color.orange)

See also

Runs on Sidechair