Mathematical/probuilder · probacktest · proorder · proscreener

EXP

EXP in ProBuilder returns e raised to the power of the input, the natural exponential function. Syntax, the inverse link to LOG, and worked code examples.

Syntax

probuilder
EXP(a)

Parameters

NameTypeDescription
anumberThe exponent to which the constant e is raised. Any real numeric expression is valid.

Formula

code
EXP(x) = e^x,   where e is approximately 2.71828

The output is always positive. Positive exponents grow the value above 1, a zero exponent returns 1, and negative exponents give a value between 0 and 1.

How it works

EXP models continuous exponential growth or decay. It accepts any real input and always returns a positive result, so it never produces zero or a negative number. Large positive exponents grow very fast, which is worth keeping in mind when the argument is derived from price.

EXP and LOG are inverses: EXP(LOG(x)) returns x for any positive x, and LOG(EXP(x)) returns x for any x. This pairing is the basis for working in log space, for example compounding returns.

Examples

Example 1, Basic exponential values (Indicator)

probuilder
// e raised to a few exponents
variable1 = EXP(1)   // approximately 2.71828
variable2 = EXP(0)   // exactly 1
variable3 = EXP(-1)  // approximately 0.36788
RETURN variable1 AS "e^1", variable2 AS "e^0", variable3 AS "e^-1"

The three calls show the growth for a positive exponent, the fixed value at zero, and the decay for a negative exponent.

Example 2, Compound a log return (ProScreener)

probuilder
// Turn a summed log return back into a price ratio
logRet = LOG(close / close[20])
ratio = EXP(logRet)
SCREENER[ratio > 1.05](ratio AS "20-bar ratio")

LOG measures the return in log space and EXP converts it back to a plain ratio, showing the round trip between the two functions.

Example 3, Exponentially decaying weight (ProOrder)

probuilder
// Weight recency with an exponential decay factor
barsSince = BarIndex - BarIndex[5]
weight = EXP(-0.2 * barsSince)
IF NOT LongOnMarket AND close CROSSES OVER Average[20](close) AND weight > 0.3 THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

The negative exponent produces a weight that decays smoothly toward zero as bars pass, a common way to emphasize recent events.

Common errors and gotchas

  • Output is always positive. EXP never returns zero or a negative value, so testing its result against a negative threshold is always false.
  • Grows very fast. A large positive argument can produce an enormous value. Keep the exponent bounded when it comes from raw price differences.
  • Inverse of LOG, not the reciprocal. EXP undoes the natural logarithm. It is not 1 / LOG. To raise an arbitrary base to a power, use Pow.
  • LOG, natural logarithm, the inverse of EXP.
  • Pow, raises any base to a power, unlike the fixed base e of EXP.
  • SQRT, square root.
  • SQUARE, squares a value.
  • ABS, absolute value.
  • ExponentialAverage, exponential moving average built on similar decay ideas.
  • ROC, rate of change, often analyzed in log space using EXP and LOG.