Mathematical/probuilder · probacktest · proorder · proscreener

ATAN

ATAN in ProBuilder returns the arc tangent of a value, the angle in radians whose tangent equals the input. Syntax, parameters, output range, examples.

Syntax

probuilder
ATAN(value)

Parameters

NameTypeDescription
valuenumberAny real numeric expression. Unlike ASIN and ACOS, there is no restricted input range.

Formula

code
ATAN(x) = angle in radians such that TAN(angle) = x

The returned angle falls between -PI/2 and PI/2 radians (-90 to 90 degrees), never reaching the endpoints. To convert to degrees, multiply by 180 / PI.

How it works

ATAN maps a slope back to the angle that produced it. Because tangent covers the whole real line, ATAN accepts any input without a domain restriction. ATAN(0) returns 0, ATAN(1) returns about 0.785 (PI/4, or 45 degrees), and large magnitudes approach but never reach +/- PI/2.

A common use is turning a slope, such as the change of a moving average per bar, into an angle. The output is in radians, matching the other trigonometric instructions, so apply 180 / PI when degrees are wanted.

Examples

Example 1, Slope of a moving average as an angle (Indicator)

probuilder
// Angle of the 20-period average measured over one bar
ma = Average[20](close)
slope = ma - ma[1]
angleDeg = ATAN(slope) * 180 / 3.14159265
RETURN angleDeg AS "MA angle (deg)"

ATAN converts the per-bar slope into an angle, giving a bounded reading that is easier to threshold than a raw slope that scales with price.

Example 2, Steeply rising averages (ProScreener)

probuilder
// Instruments whose 50-period average is angled sharply upward
ma = Average[50](close)
ang = ATAN(ma - ma[1])
SCREENER[ang > 0.02](ang AS "Slope angle")

Because ATAN accepts any input, the slope needs no clamping before the call.

Example 3, Trend-angle entry filter (ProOrder)

probuilder
// Enter long only when the trend angle is positive enough
ma = Average[30](close)
theta = ATAN(ma - ma[1])
IF NOT LongOnMarket AND close CROSSES OVER ma AND theta > 0.01 THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

The angle filter demands a genuinely rising average, not merely a crossover on a flat line.

Common errors and gotchas

  • Result is in radians. The output ranges from -PI/2 to PI/2 and never reaches those limits. Multiply by 180 / PI if you need degrees.
  • Inverse of TAN, not 1 / TAN. ATAN undoes tangent. It is not the reciprocal of TAN.
  • Angle depends on scale. The angle from ATAN(slope) depends on the units of the slope. A price slope on an index and a forex pair map to very different angles, so an absolute angle threshold is not comparable across instruments.
  • ACOS, arc cosine, the inverse of COS.
  • ASIN, arc sine, the inverse of SIN.
  • TAN, tangent of an angle in radians, the function ATAN reverses.
  • SIN, sine of an angle in radians.
  • COS, cosine of an angle in radians.
  • ABS, absolute value, useful for symmetric angle tests.
  • LinearRegressionSlope, slope of a fitted line, a natural input to ATAN.