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[1]);
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);
AdaptMA = AdaptMA[1] + Smooth * (Close — AdaptMA[1]);
End;
AMA = AdaptMA;

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[1]);
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);
AdaptMA = AdaptMA[1] + Smooth * (Close — AdaptMA[1]);
AMAFltr = StdDev(AdaptMA-AdaptMA[1], Period) * Pcnt;
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
Plot2(AMA(Period), «Adaptive MA»);

ADAPTIVE MOVING AVERAGE BY PERRY KAUFMAN

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

ADAPTIVE MOVING AVERAGE BY PERRY KAUFMAN

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[1] Then
AMALs = AMAVal;
IF AMAVal > AMAVal[1] Then
AMAHs = AMAVal;
IF AMAVal — AMALs > AMAFVal Then Begin
Plot1(AMAFVal, «Buy»);
IF Plot1[1] = 0 Then
Alert = True;
End Else
IF AMAHs — AMAVal > AMAFVal Then Begin
Plot2(AMAFVal, «Sell»);
IF Plot2[1] = 0 Then
Alert = True;
End;
Plot3(AMAFVal, «AMAFilter»);
End;

Подписаться
Уведомить о
0 комментариев
Межтекстовые Отзывы
Посмотреть все комментарии