submit content
Automated Trading Resources & Tools

Indicators & more > TradeStation > Adaptive Moving Average



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 on 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.

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."

The second indicator, "Mov Avg Adaptive Fltr," takes the filtering concept and applies it to an indicator. Based on the filtered adaptive moving average (AMAF) parameters, this indicator will plot a vertical blue or red line, depending on 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.

Style:

Plot Name Type Color Weight
Plot1 Buy Histogram Blue Thinnest
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.

-- Gaston Sanchez, Omega Research
800 422-8587, 305 270-1095
Internet: http://www/omegaresearch.com

 

 



Code:

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;


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");

 

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;


 





                                           



Author: Perry Kaufmann
Source: http://www.traders.com


All content is submitted by anonymous users. 
Therefore S4T™ does not take any responsibility for it's quality and copyright violations.

If you use any of this information, use it at your own risk. You are responsible for your own trading decisions. 
Be sure to verify that any information you see on these pages is correct, and is applicable to your particular trade. 
In no case will S4T™ be responsible for your trading gains or losses.
 
StatCounter - Free Web Tracker and Counter  
 
Privacy note | (c) copyrights systems4trading.com 2006-2012