Mathematical/probuilder · probacktest · proorder · proscreener

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

probuilder
SIN(a)

Parameters

NameTypeDescription
anumberThe angle in radians. Degrees must be converted to radians before the call.

Formula

code
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)

probuilder
// 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)

probuilder
// 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)

probuilder
// 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
ENDIF

The 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. SIN expects radians. To use degrees, multiply by PI / 180 first, 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) and SIN(a + 2*PI) are equal, so the function alone cannot say which cycle an angle belongs to.
  • COS, cosine of an angle in radians, the companion of sine.
  • TAN, tangent of an angle in radians.
  • ASIN, arc sine, the inverse of SIN.
  • ACOS, arc cosine.
  • ATAN, arc tangent.
  • ABS, absolute value, useful for symmetric sine tests.
  • SQRT, square root, common in trigonometric identities.