Mathematical/probuilder · probacktest · proorder · proscreener

Pow

Pow in ProBuilder raises a base value to an exponent, computing base to the power. Argument order, syntax, link to SQRT and SQUARE, and worked examples.

Syntax

probuilder
POW(BaseValue, Power)

Parameters

NameTypeDescription
BaseValuenumberThe base to be raised.
PowernumberThe exponent the base is raised to. Can be a whole number or a fraction.

Formula

code
POW(x, y) = x^y

POW(2, 3) is 8, POW(9, 0.5) is 3 (the square root), and POW(x, 0) is 1 for any non-zero base.

How it works

POW raises the first argument to the power of the second. Argument order matters: POW(2, 3) is 8 but POW(3, 2) is 9. A whole-number exponent gives repeated multiplication, while a fractional exponent gives a root, so POW(x, 0.5) equals SQRT(x) and POW(x, 2) equals SQUARE(x).

For the fixed base e, EXP is the specialized function. POW covers any base, which is useful for compounding at an arbitrary rate or for custom power weightings.

Examples

Example 1, Two cubed (Indicator)

probuilder
// Raise 2 to the power of 3
result = POW(2, 3)   // 8
RETURN result AS "2^3"

The base 2 is raised to the exponent 3, giving 8. Swapping the arguments would return 9 instead.

Example 2, Cube a normalized ratio (ProScreener)

probuilder
// Emphasize large ratios by cubing them
ratio = close / Average[50](close)
cubed = POW(ratio, 3)
SCREENER[cubed > 1.2](cubed AS "Ratio cubed")

Cubing amplifies values above 1 and shrinks values below it, sharpening the separation between strong and weak instruments.

Example 3, Compound a per-bar growth rate (ProOrder)

probuilder
// Project a fixed daily growth rate over 5 bars
rate = 1.002
factor = POW(rate, 5)
IF NOT LongOnMarket AND close > close[5] * factor THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

POW(rate, 5) compounds the per-bar rate across five bars, giving the growth factor the current price is compared against.

Common errors and gotchas

  • Base first, exponent second. POW(2, 3) is 8, POW(3, 2) is 9. Swapping the arguments changes the result.
  • Fractional exponents are roots. POW(x, 0.5) is the square root of x and is only real for x >= 0, the same domain limit as SQRT.
  • Uppercase name in code. The documented display name is Pow, but the call is written POW(...). ProBuilder keywords are not case sensitive, so either casing works.
  • SQRT, square root, equivalent to POW(x, 0.5).
  • SQUARE, squares a value, equivalent to POW(x, 2).
  • EXP, exponential with the fixed base e.
  • LOG, natural logarithm, the inverse of exponentiation.
  • ABS, absolute value, useful before fractional powers.
  • MAX, larger of two values.
  • MIN, smaller of two values.