Автор:
Разместил:   Дата: 2005-09-09 09:21
Комментарии: (0)   Рейтинг:

# Adaptive Moving Average System by Perry Kaufman

The adaptive moving average that was discussed in the interview with Perry Kaufman in the 1998 STOCKS & COMMODITIES Bonus Issue (the article originally appeared in March 1995) is an excellent alternative to standard moving average calculations. In this month's Traders' Tips, I will present two Easy Language studies and an Easy Language system that are based o­n the adaptive moving average.

The adaptive moving average calculation that is used in the studies and system in TradeStation or SuperCharts is performed primarily by a function referred to as "AMA." Another function referred to as "AMAF" is used to calculate the adaptive moving average filter. As always, the functions should be created prior to the development of the studies/system.

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;

Once you have successfully created both functions, you can then create the two studies and the system. The first indicator displays the adaptive moving average line, with an optional twist. The twist is that the AMA line can be smoothed using linear regression. Thus, I have included in the indicator an input named "smooth" that allows you to determine if the AMA line should be smoothed or not. A "Y" as the input value smoothes the calculation. An "N" simply plots the raw AMA line. This indicator should be scaled to "Same as price data."

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, "Mov Avg Adaptive Fltr," takes the filtering concept and applies it to an indicator. Based o­n the filtered adaptive moving average (AMAF) parameters, this indicator will plot a vertical blue or red line, depending o­n the condition that is met. The values reflected by the vertical lines reflect the value of the AMA filter calculation. Some suggested format settings are given after the indicator code.

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
End;
Plot3(AMAFVal, "AMAFilter");
End; Style:

Plot   Name        Type        Color      Weight
Plot2   Sell        Histogram   Red        Thinnest
Plot3   AMAFilter   Line        Magenta    Thinnest

Scaling: Screen

This code is also available at Omega Research's Web site. The name of the file is "AMA.ELA." Please note that all Traders' Tips analysis techniques posted at Omega Research's Web site can be utilized by both TradeStation and SuperCharts. Whenever possible, the posted analysis techniques will include both Quick Editor and Power Editor formats.

Реклама:  Страница создана за 0.8 секунды