SIN
SIN in ProBuilder returns the sine of an angle given in radians, a value between -1 and 1. Syntax, the radian requirement, gotchas and worked examples.
Syntax
SIN(a)Parameters
| Name | Type | Description |
|---|---|---|
a | number | The angle in radians. Degrees must be converted to radians before the call. |
Formula
SIN(a) = sine of angle a, with a in radians, result in [-1, 1]SIN(0) returns 0, SIN(PI/2) returns 1, and SIN(PI) returns 0. The function is periodic with period 2*PI.
How it works
SIN treats its argument as an angle measured in radians. Passing a degree value directly gives a meaningless result, so convert first with a * PI / 180. The output stays inside [-1, 1], which makes sine a natural building block for smooth cyclic series and oscillators.
Because the result never leaves [-1, 1], it is a safe input for ASIN, its inverse, without clamping.
Examples
Example 1, Sine of an angle in degrees (Indicator)
// Convert 90 degrees to radians, then take the sine
angleInDegrees = 90
angleInRadians = angleInDegrees * 3.14159265 / 180
result = SIN(angleInRadians)
RETURN result AS "SIN(90 deg)"The conversion matters. SIN(90) would treat 90 as radians; the code above returns 1, the sine of 90 degrees.
Example 2, Cyclic wave over the bar index (ProScreener)
// A smooth sine wave cycling every 20 bars
phase = BarIndex * 2 * 3.14159265 / 20
wave = SIN(phase)
SCREENER[wave > 0.9](wave AS "Sine wave")Scaling the bar index into radians produces a repeating sine that peaks once per cycle.
Example 3, Sine-weighted entry gate (ProOrder)
// Allow entries only during the rising half of a slow sine cycle
phase = BarIndex * 2 * 3.14159265 / 50
weight = SIN(phase)
IF NOT LongOnMarket AND close CROSSES OVER Average[20](close) AND weight > 0 THEN
BUY 1 CONTRACT AT MARKET
ENDIFThe sine term restricts entries to the positive half of its cycle, biasing trades toward one phase of the wave.
Common errors and gotchas
- Angle must be in radians.
SINexpects radians. To use degrees, multiply byPI / 180first, otherwise the result is meaningless. - Output is bounded to [-1, 1]. Sine never returns a value outside this range, so a reading beyond it signals a coding mistake upstream.
- Periodic, so many inputs give the same output.
SIN(a)andSIN(a + 2*PI)are equal, so the function alone cannot say which cycle an angle belongs to.
