# ADAPTIVE MOVING AVERAGE BY PERRY KAUFMAN

The adaptive moving average, which was mentioned in an interview with Perry Kaufman in Stocks&Commodities magazine 1998, is an excellent alternative to the well-known moving averages.

To calculate the Adaptive Moving Average, functions called «AMA» and «AMAF» are first programmed. The functions must be created before the indicator programming begins.

Type: Function, Name: AMA

Inputs: Period(Numeric);
Vars: Noise(0), Signal(0), Diff(0), efRatio(0), Smooth(1), Fastest(.6667), Slowest(.0645), AdaptMA(0);
Diff = AbsValue(Close — Close);
IF CurrentBar <= Period Then AdaptMA = Close;
IF CurrentBar > Period Then Begin
Signal = AbsValue(Close — Close[Period]);
Noise = Summation(Diff, Period);
efRatio = Signal / Noise;
Smooth = Power(efRatio * (Fastest — Slowest) + Slowest, 2);
End;

Type: Function, Name: AMAF

Inputs: Period(Numeric), Pcnt(Numeric);
Vars: Noise(0), Signal(0), Diff(0), efRatio(0), Smooth(1), Fastest(.6667), Slowest(.0645), AdaptMA(0), AMAFltr(0);
Diff = AbsValue(Close — Close);
IF CurrentBar <= Period Then AdaptMA = Close;
IF CurrentBar > Period Then Begin
Signal = AbsValue(Close — Close[Period]);
Noise = Summation(Diff, Period);
efRatio = Signal / Noise;
Smooth = Power(efRatio * (Fastest — Slowest) + Slowest, 2);
End;
AMAF = AMAFltr;

After you have successfully created both functions, you can create two indicators based on them. The first indicator displays an Adaptive Moving Average as a line. The trick is that the ACC line can be smoothed using linear regression.

Type: Indicator, Name: Adaptive Moving Average

Inputs: Period(10), Smooth(«Y»);
IF UpperStr(Smooth) = «Y» Then
Plot1(LinearRegValue(AMA(Period), Period, 0), «Smooth AMA»)
Else The second indicator, «AMA Fltr», uses the concept of filtering. Based on the filtered parameters of the adaptive moving average (AMA), we have an indicator that shows the location of the price relative to the AMA in the form of vertical blue or red lines.

Plot1 Purchase Blue Line

Plot2 Sale of the Red Line

Plot3 AMAFILTER Type: Indicator, Name: Adaptive Moving Average Fltr

Inputs: Period(10), Pcnt(.15);
Vars: AMAVal(0), AMAFVal(0), AMALs(0), AMAHs(0);
AMAVal = AMA(Period);
AMAFVAl = AMAF(Period, Pcnt);
IF CurrentBar = 1 Then Begin
AMALs = AMAVal;
AMAHs = AMAVal;
End Else Begin
IF AMAVal < AMAVal Then
AMALs = AMAVal;
IF AMAVal > AMAVal Then
AMAHs = AMAVal;
IF AMAVal — AMALs > AMAFVal Then Begin
IF Plot1 = 0 Then
End Else
IF AMAHs — AMAVal > AMAFVal Then Begin
Plot2(AMAFVal, «Sell»);
IF Plot2 = 0 Then