The AMA Filtered indicator combines Kaufman’s Adaptive Moving Average (AMA) with a statistical volatility filter. The AMA adjusts its smoothing speed based on market efficiency: it accelerates during clear trends and slows down during choppy, directionless price action.
On top of that, the statistical filter suppresses minor fluctuations that fall below a volatility threshold, keeping the output flat until a meaningful move is confirmed.
The result is a single colored line that stays remarkably still during noise and reacts quickly when a real trend develops.
Adaptive Moving Average (AMA): The core engine measures price efficiency over a lookback window. It computes a multiplier based on how far the current price sits within the recent high-low range. This multiplier blends between a fast and a slow smoothing constant, producing a variable-speed EMA. When price moves decisively in one direction, the AMA tracks closely. When price chops sideways, the AMA barely moves.
Statistical filter: The raw AMA output is then passed through a volatility filter. The indicator calculates the standard deviation of bar-to-bar AMA changes over the same lookback period. If the current change is smaller than a configurable multiple of that standard deviation, the filtered value holds its previous level. This eliminates whipsaws caused by insignificant price movements. Setting the filter multiplier to zero disables this layer entirely.
Color coding: The line is colored green (MediumSeaGreen) when the filtered value is rising, red (OrangeRed) when it is falling, and gray during the warmup phase. The color persists when the filtered value is flat, retaining the last directional state.
period (default: 17) — Lookback window used both for the AMA efficiency calculation and for the statistical filter. Higher values make the indicator smoother but slower to react.
fastPeriod (default: 3) — Fast end of the smoothing spectrum. The AMA approaches this speed during strong trends. Lower values increase responsiveness.
slowPeriod (default: 34) — Slow end of the smoothing spectrum. The AMA approaches this speed during noisy, range-bound conditions. Higher values add more smoothing.
filterSize (default: 5) — Multiplier for the volatility filter threshold. Higher values filter out more movement, keeping the line flat longer. Set to 0 to disable the filter and output the raw AMA.
//--------------------------------------------
// PRC_AMA Filtered (from MT5 by mladen)
// version = 0
// 04.03.2026
// Iván González @ www.prorealcode.com
// Sharing ProRealTime knowledge
//--------------------------------------------
// Parámetros:
// period = ventana para eficiencia y filtro (17)
// fastPeriod = extremo rápido AMA (3)
// slowPeriod = extremo lento AMA (34)
// filterSize = multiplicador filtro (5), <=0 para desactivar
//--------------------------------------------
// --- Parámetros ---
//--------------------------------------------
period = 17
fastPeriod = 3
slowPeriod = 34
filterSize = 5
//--------------------------------------------
// --- Constantes derivadas ---
//--------------------------------------------
fastEnd = 2 / (fastPeriod + 1)
slowEnd = 2 / (slowPeriod + 1)
hlPeriod = period + 1
//--------------------------------------------
// --- Fuente ---
//--------------------------------------------
src = close
//--------------------------------------------
// --- AMA: Adaptive Moving Average ---
//--------------------------------------------
hhVal = highest[hlPeriod](high)
llVal = lowest[hlPeriod](low)
IF hhVal <> llVal THEN
mltp = ABS(((src - llVal) - (hhVal - src)) / (hhVal - llVal))
ELSE
mltp = 1
ENDIF
ssc = mltp * (fastEnd - slowEnd) + slowEnd
IF barindex < hlPeriod THEN
amaVal = src
ELSE
amaVal = amaVal[1] + (ssc * ssc) * (src - amaVal[1])
ENDIF
//--------------------------------------------
// --- Filtro estadístico ---
// Suprime movimientos menores que filterSize * stddev(cambios)
// Warmup: hlPeriod (AMA estable) + period (summation completa)
//--------------------------------------------
warmup = hlPeriod + period
IF barindex < hlPeriod THEN
filtVal = src
chgVal = 0
pwrVal = 0
ELSIF barindex < warmup THEN
// AMA ya calcula pero filtro aún sin datos suficientes
filtVal = amaVal
chgVal = ABS(amaVal - filtVal[1])
pwrVal = 0
ELSE
chgVal = ABS(amaVal - filtVal[1])
sumChg = summation[period](chgVal)
avgChg = sumChg / period
pwrVal = SQUARE(chgVal - avgChg)
sumPwr = summation[period](pwrVal)
IF filterSize > 0 AND chgVal < filterSize * SQRT(sumPwr / period) THEN
filtVal = filtVal[1]
ELSE
filtVal = amaVal
ENDIF
ENDIF
//--------------------------------------------
// --- Colores: verde alcista, rojo bajista, gris neutro ---
//--------------------------------------------
IF barindex < warmup THEN
rr = 128
gg = 128
bb = 128
ELSIF filtVal > filtVal[1] THEN
// Verde (MediumSeaGreen)
rr = 60
gg = 179
bb = 113
ELSIF filtVal < filtVal[1] THEN
// Rojo (OrangeRed)
rr = 255
gg = 69
bb = 0
ELSE
rr = rr[1]
gg = gg[1]
bb = bb[1]
ENDIF
//--------------------------------------------
RETURN filtVal COLOURED(rr, gg, bb) style(line, 2) AS "AMA Filtered"