KAMA

Calculates the Kaufman's Adaptive Moving Average indicator.

Accepts the following parameters:

Parameter NameTypeDefault ValueNotes
periodNumber10-
fastSmoothingNumber2-
slowSmoothingNumber30-

Returns: Series<Number>

KAMA is a built-in function - you can use it directly. Below is an example implementation:

1234567891011121314
function KAMA(period = 10, fastSmoothing = 2, slowSmoothing = 30):
# Efficiency Ratio (ER)
change = Math.Abs(close - close[period])
volatility = Sum(Math.Abs(close - close[1]), period)
ER = change / volatility

# Smoothing Constant (SC)
fastSC = 2 / (fastSmoothing + 1)
slowSC = 2 / (slowSmoothing + 1)
SC = (ER * (fastSC - slowSC) + slowSC) ** 2

series KAMA: once: SMA(close, period) rest: SC * close + (1 - SC) * KAMA