Indicators/probuilder · probacktest · proorder · proscreener

AdaptiveAverage

AdaptiveAverage in ProBuilder returns the Adaptive Moving Average, a moving average that adjusts its speed to volatility. Syntax, parameters, examples.

Syntax

probuilder
AdaptiveAverage[MAperiod, fastSC, slowSC](price)

Parameters

NameTypeDefaultDescription
MAperiodinteger9Lookback period used to measure how directional recent price movement has been.
fastSCinteger2Fast smoothing constant period. Controls how quickly the average reacts when price trends cleanly.
slowSCinteger30Slow smoothing constant period. Controls how sluggish the average becomes when price is noisy.
priceprice sourcecloseThe price series being smoothed, such as close, open, or typicalprice.

Formula

code
ER    = Abs(price - price[MAperiod]) / Sum of Abs(price - price[1]) over MAperiod bars
fast  = 2 / (fastSC + 1)
slow  = 2 / (slowSC + 1)
SC    = (ER * (fast - slow) + slow)^2
AMA   = AMA[1] + SC * (price - AMA[1])

ER is the efficiency ratio. It approaches 1 when price travels in a straight line over the lookback window and approaches 0 when price moves back and forth without net progress. The squared smoothing constant SC then interpolates between the fast and slow EMA speeds.

How it works

A fixed-period moving average forces one compromise on every market condition: short periods whipsaw in ranges, long periods lag in trends. The Adaptive Moving Average sidesteps the compromise by recalculating its own smoothing constant on every bar.

When the efficiency ratio is high, meaning recent bars moved mostly in one direction, the smoothing constant shifts toward the fast end and the average hugs price closely. When the ratio is low, meaning price covered a lot of distance but ended up nowhere, the constant shifts toward the slow end and the average flattens out, ignoring the noise.

The practical effect is a line that flattens during consolidations and accelerates once a directional move begins. This reduces both the lag penalty of slow averages and the whipsaw penalty of fast ones, at the cost of an extra two parameters to configure.

Examples

Example 1, Standard AMA on closing prices (Indicator)

probuilder
// Adaptive average: 9-bar efficiency window, fast constant 2, slow constant 30
myAMA = AdaptiveAverage[9, 2, 30](close)
RETURN myAMA

The classic configuration. Plotted on the price chart, the line stays close to price in trends and goes nearly horizontal during sideways phases.

Example 2, Adaptive trend filter for entries (ProOrder)

probuilder
// Trade long only while price holds above a flattening-resistant average
ama = AdaptiveAverage[10, 2, 30](close)

IF NOT LongOnMarket AND close CROSSES OVER ama THEN
  BUY 1 CONTRACT AT MARKET
ENDIF

IF LongOnMarket AND close CROSSES UNDER ama THEN
  SELL AT MARKET
ENDIF

A crossover system using the adaptive line instead of a fixed-period average. Because the AMA flattens in ranges, crossovers during consolidation cluster less than with a simple moving average of similar speed.

Example 3, Screening for price above a rising AMA (ProScreener)

probuilder
// Instruments trading above an adaptive average that slopes upward
ama = AdaptiveAverage[9, 2, 30](close)
rising = ama > ama[5]
SCREENER[close > ama AND rising]((close / ama - 1) * 100 AS "% above AMA")

Returns instruments where price sits above an upward-sloping adaptive average, sorted by percentage distance from the line.

Interpretation

ObservationReading
Price above a rising AMADirectional up move in progress.
Price below a falling AMADirectional down move in progress.
AMA nearly flatLow efficiency ratio, price is ranging. Crossover signals are unreliable here.
AMA slope steepensThe efficiency ratio is rising, movement is becoming more one-directional.

The flat-line state is informative on its own. Many systems use AMA slope as a regime filter, only accepting signals from other indicators while the adaptive line has a clear slope.

Common errors and gotchas

  • Parameter order matters. The signature is [MAperiod, fastSC, slowSC]. Swapping the fast and slow constants, for example [9, 30, 2], inverts the adaptive behaviour and produces a line that speeds up in noise and slows down in trends.
  • Smoothing constants are periods, not alphas. fastSC and slowSC are expressed as equivalent EMA periods (2 and 30), not as decimal smoothing factors. Passing 0.6667 where 2 is expected does not raise an error but yields a different calculation than intended.
  • Crossovers still fail in tight ranges. The AMA reduces whipsaws, it does not remove them. In very narrow ranges, price can straddle the flat line repeatedly. A minimum-slope or minimum-distance condition filters most of these.
  • Short MAperiod destabilises the efficiency ratio. Values below roughly 5 make the ratio jump erratically bar to bar, which defeats the purpose of adaptation. Keep the efficiency window at moderate length and tune responsiveness with the smoothing constants instead.