Mathematical/probuilder · probacktest · proorder · proscreener

ASIN

ASIN in ProBuilder returns the arc sine of a value, the angle in radians whose sine equals the input. Input range, radian output, syntax and examples.

Syntax

probuilder
ASIN(value)

Parameters

NameTypeDescription
valuenumberA value between -1 and 1 inclusive. Inputs outside this range are invalid because sine never exceeds those bounds.

Formula

code
ASIN(x) = angle in radians such that SIN(angle) = x,   -1 <= x <= 1

The returned angle falls between -PI/2 and PI/2 radians (-90 to 90 degrees). To convert the result to degrees, multiply by 180 / PI, which is roughly 57.2958.

How it works

ASIN reverses the sine relationship: it maps a ratio back to the angle that produced it. Since sine only ever ranges from -1 to 1, the input must stay inside that band. ASIN(0) returns 0, ASIN(0.5) returns about 0.5236 (PI/6), and ASIN(1) returns roughly 1.5708 (PI/2).

The output is in radians, matching SIN, COS and TAN. Apply the 180 / PI factor afterward if a later step works in degrees.

Examples

Example 1, Angle from a sine ratio (Indicator)

probuilder
// Recover an angle in degrees from a sine ratio
ratio = 0.5
angleRad = ASIN(ratio)
angleDeg = angleRad * 180 / 3.14159265
RETURN angleDeg AS "Angle (deg)"

ASIN(0.5) returns about 0.5236 radians, which the conversion turns into 30 degrees.

Example 2, Scan bounded readings (ProScreener)

probuilder
// Map a clamped oscillator to an angle and screen on it
x = (close - Average[20](close)) / (2 * STD[20](close))
x = MIN(1, MAX(-1, x))
angle = ASIN(x)
SCREENER[angle > 0](angle AS "ASIN")

Clamping x into [-1, 1] first makes sure ASIN always receives a valid sine value.

Example 3, Angle threshold on entries (ProOrder)

probuilder
// Gate long entries by an angle derived from a normalized ratio
r = (close - Lowest[14](low)) / (Highest[14](high) - Lowest[14](low)) * 2 - 1
r = MIN(1, MAX(-1, r))
theta = ASIN(r)
IF NOT LongOnMarket AND theta > 0.5 THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

Rescaling the stochastic-style ratio into [-1, 1] keeps the ASIN input legal, and the resulting angle acts as the entry filter.

Common errors and gotchas

  • Input must stay in [-1, 1]. An argument outside that range is not a valid sine and raises an error. Clamp with MIN(1, MAX(-1, x)) when the value can leave the band.
  • Result is in radians. The output ranges from -PI/2 to PI/2. Multiply by 180 / PI if you need degrees.
  • Inverse of SIN, not 1 / SIN. ASIN undoes sine. It is not the reciprocal of SIN.
  • ACOS, arc cosine, the inverse of COS.
  • ATAN, arc tangent, the inverse of TAN.
  • SIN, sine of an angle in radians, the function ASIN reverses.
  • COS, cosine of an angle in radians.
  • TAN, tangent of an angle in radians.
  • ABS, absolute value, useful when preparing inputs.
  • SQRT, square root, common alongside trigonometric ratios.