[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[EquisMetaStock Group] Re: Adaptive Moving Average



PureBytes Links

Trading Reference Links

------------------------------------------------------------------------
You cannot reply to this message via email because you have chosen not
to disclose your email address to the group.

To reply:  http://groups.yahoo.com/group/equismetastock/post?act=reply&messageNum=5369
------------------------------------------------------------------------

Here is some additional information I just found in S&C Magazine 
06/1995: Kaufman has another article in the same issue, "A guide to 
Smarter Trading."  
"ADAPTIVE MOVING AVERAGE
Perry Kaufman points out in Smarter Trading that if you could achieve 
only one goal in analyzing the price of
investments, it should be to identify the direction, or trend, of the 
market involved. Further, he writes that "everyone
wants a short-term, fast trading trend that works without large 
losses. That combination does not exist." It is
possible to have fast trading trends in which one must get in or out 
of the market quickly, but these have the distinct
disadvantage of being whipsawed by market noise when the market is 
volatile in a sideways trending market. During
these periods, the trader is jumping in and out of positions with no 
profit-making trend in sight. However, it is
possible to avoid the noise by using very long moving averages. These 
are little affected by the day-to-day changes
in price, but they also miss much of the profit to be gained, or 
saved as the case may be, by the lag between the time
that the trend actually changes and the moving average gives a buy or 
sell signal.
In an attempt to overcome the problem of noise and still be able to 
get closer to the actual change of the trend,
Kaufman developed an indicator that adapts to market movement. This 
indicator, an adaptive moving average
(AMA), moves very slowly when markets are moving sideways but moves 
swiftly when the markets also move
swiftly, change directions or break out of a trading range.
SIDEBAR FIGURE 1: MICROSOFT EXCEL SPREADSHEET: Here's the AMA using 
the efficiency
ratio to adjust the speed of the moving average.
In order to construct the AMA, many different qualities of the market 
must be known. First is the price direction , or
the net price change over n days. This is the difference between the 
price today and the price n days ago. Kaufman
uses n of 10 days in Smarter Trading :
Direction = Price - price(n )
In the accompanying spreadsheet in sidebar Figure 1, the formula to 
measure price direction is entered in cell D15
and copied down to the end of the available data. In Microsoft Excel, 
it looks like this:
=C15-C5
The volatility , or noise, is the sum of the absolute values of the 
daily price changes over n days and is always
expressed as positive:
Volatility = Sum (abs (price-price[1]),n )
To be able to have a sum of absolute individual daily values, we must 
have those values to add. To get daily
volatility, we put this formula in cell E6 and copy down:
=ABS(C6-C5)
Then to get the 10-day volatility needed for use in the spreadsheet, 
this formula is entered in cell F15 and copied
down:
=SUM(E6:E15)
The efficiency ratio (ER), sometimes referred to as generalized 
fractal efficiency , is a combination of direction and
volatility:
Efficiency ratio = direction/volatility
As the direction is indicated in column D, and volatility is in 
column F, the efficiency ratio is calculated next. Enter
into cell G15 the following formula and copy down:
=ABS(D15/F15)
As long as the market is moving in the same direction for all n days, 
volatility and direction are the same and the ER
= 1. But when the market just moves up and down in a sideways 
pattern, then direction is zero and therefore ER
moves toward a value of zero. This ER can be applied to any trend 
speed, with the fastest having an ER of 1 and the
slowest having an ER of zero. The ER itself is expressed as a 
percentage between the two extremes.
An exponential moving average (EMA) uses a smoothing constant (sc) 
and the approximate speed of the trend can be
changed into a smoothing constant for any given n days by using the 
formula
sc = 2/(n +1)
The smaller the n , the faster the speed of the EMA. Likewise, the 
larger the n, the slower the speed of the EMA.
In the spreadsheet, the smoothing constants used are the following 
formulas, which are entered into cells C2 and D2
with the values of two and 30 substituted for n , respectively, as 
used in this example.
In cell C2: =2/(2+1)
In cell D2: =2/(30+1)
By using both a slow and fast smoothing constant in combination with 
the ER, it is possible to develop a scaled
smoothing constant (ssc). The ER is used as a percentage to scale the 
smoothing constant, used by the AMA,
between the fast and slow speeds.
Scaled smoothing constant = ER (fast sc - slow sc) + slow sc
The periods of two and 30 days are used to give us the fast sc and 
slow sc. Using the formula for sc = 2/n +1 for
the faster sc = 2/(2+1) or 0.6667 and the slower sc = 2/(30+1) or 
0.0645:
ssc = ER (0.6667-0.0645) + 0.0645 = ER (0.6022 + 0.0645)
This ssc is then squared to bring its movement nearly to a stop in a 
market that is mostly noise and little actual
movement.
c = (ssc)(ssc)
When the ssc is squared, it becomes the constant (c ) in the formula 
for the AMA. The complete formula for c is
entered into cell H15 and copied down:
=(G15*($C$2-$D$2)+$D$2)^2
This scaling of the trend speed makes it adaptive to the market's 
movements. The adaptive moving average is
recalculated every day using this formula:
AMA = AMA[1] + c (price - AMA[1])
Enter the following formula into cell I15 and copy down:
=I14+H15*(C15-I14)
Note that in cells I5 through I14, the actual values from column C 
must be used, as 10 days of data is needed prior to
the formula being usable.
To use the AMA in trading, there are two basic rules: Buy when the 
AMA turns up, and sell when the AMA turns
down. As with any trading system that uses trends, there must be some 
kind of filter to remove false trading signals.
As with the rest of the system, it should be able to adapt itself to 
the market conditions. This filter would be a small
percentage of the AMA trendline. In the example given, the percentage 
is 0.15 and is entered as such into cell J2. The
formula for the filter is:
filter = (percentage)(standard deviation)(AMA - AMA[1], n )
In order to be able to use this formula, the difference in today's 
AMA and yesterday's AMA, or AMA[1], must be
known. To ascertain that data, the following is placed in cell J6 and 
is copied down:
=I6-I5
With this information, the formula for the filter can now be placed 
in cell K15 and is copied down:
=STDEVP(J6:J15)*$J$2
To add the filter, the AMA trading system changes the rules to buy 
when the AMA - lowest AMA is greater than the
filter, and sell when the highest AMA - AMA is greater than the 
filter. Finding the lowest and highest AMA uses two
different columns, columns L and M. Each day's AMA value is compared 
with yesterday's low value for the AMA.
If the AMA today is lower than the recent low, it is returned in the 
formula; otherwise, the current low AMA value is
returned. To do this in cell L6, the low AMA is determined by using 
the following formula and copying down:
=IF(I6<I5,I6,L5)
In like manner, cell M6 has the formula for the high AMA:
=IF(I6>I5,I6,M5)
It is now possible to put into the spreadsheet the finalized versions 
of the rules for using the filtered AMA trading
system. The spreadsheet will now give a buy or sell signal for each 
day. Only the first of each signal would be used.
That position would be carried until the opposite signal is given. 
For the buy signal, in cell N15 insert:
=IF((I15-L15)>K15,"BUY","")
For the sell signal, this is placed in cell O15:
=IF((M15-I15)>K15,"SELL","")
The data in columns B and C must be input. The data/formulas in row 2 
are input only once. The data in L5 and M5
are the same as that in I5. The formulas in the rest of the cells 
mentioned are entered and then copied down to the end
of the data in column C (except I5 to I14 as described above).


--- In equismetastock@xxxx, "grizz003" <grizz002@xxxx> wrote:
> >By the way: Grizz, would you mind telling us where that you did 
find 
> >your code(s)? Thanks a lot!
> 
> praktikus and all,
> I find nearly all of the codes that I don't create myself at one of 
> these sites: 
>   http://eis.pl/kr/AFM/index-en.html
>      look under K for Kaufman
>   www.guppytraders.com/Metastock%20Formulas/formula%20index.htm  
>      look under A for adaptive moving average.
> Many thanks for the explanation. I think I see the light. I'm going 
> to go play with it for a while to see if I can better understand 
what 
> is going on there.  
> 
> Grizz
> 
> --- In equismetastock@xxxx, "praktikus_ms" <mluescher@xxxx> wrote:
> > Grizz
> > 
> > Her is what Kaufman says in his book:
> > 
> > Basic Buy and Sell Signals
> > --------------------------
> > 
> > The trading rules for the AMA are:
> > 
> > - Buy when the AMA turns up.
> > 
> > - Sell when the AMA turns down.
> > 
> > ...
> > 
> > 
> > A Filter for False Signals
> > --------------------------
> > 
> > A filter is nneded for any trending system to avoid false signals 
> > caused by noise when prices are moving sideways. During a 
> > nondirectional period, prices will move back and forth trough the 
> > smoothed trendline value. This affects all moving average systems 
> in 
> > the same way, but it is more obvious with faster trends. The 
> > trendline must move higher or lower by the amount of the filter 
to 
> > qualify for a trading signal. ...
> > 
> > Self-Adjusting filter:
> > To be consistent with the adaptive nature of the system, the 
filter 
> > will be also get larger and smaller when prices become more or 
less 
> > volatile. To accomplish this, the filter is defined as a small 
> > percentage of the changes in the AMA-Trendline:
> > 
> >      filter = percentage x @std_dev(AMA - AMA[1],n)
> > 
> > where percentage is the percentage of 1 standard deviation,
> >       @std_dev(series,n) is the standard deviation of "series 
over 
> n 
> > periods", and
> >       AMA - is the 1 day change in the AMA trendline.
> > 
> > The smallest filter percentages of 0.01 can be used for faster 
> > trading, while the larger percentages of 1.0 select those trades 
> that 
> > have had a more significant price move. ... Normally the filter 
is 
> > calculated over a period of 20 days.
> > 
> > ... 
> > 
> > Because a slow trend change may result in a series of days wich 
> fail 
> > to penetrate the filter, the net change over 1 to three days is 
> > substituted for a sigle day.
> > 
> > The new rules for trading signals are 
> > 
> > - Buy when AMA - @lowest(AMA,n) > filter
> > 
> > - Sell when @highest(AMA,n) - AMA > filter
> > 
> > 
> > Grizz, as you can see Kaufman uses 10 periods for the AMA itself 
> and 
> > 20 periods for the filter. From this text I made the following 
> system:
> > 
> > ------------------------------------------
> > {ama}
> > 
> > Direction:=CLOSE - Ref(CLOSE,-10);
> > Volatility:=Sum(Abs(ROC(CLOSE,1,$)),10);
> > ER:=Abs(Direction/Volatility);
> > FastSC:=2/(2+1);
> > SlowSC:=2/(30+1);
> > SSC:=ER*(FastSC-SlowSC)+SlowSC;
> > Constant:=Pwr(SSC,2);
> > If(Cum(1)=10+1,Ref(CLOSE,-1)+constant*(CLOSE-Ref(CLOSE,-
> > 1)),PREV+constant*(CLOSE-PREV));
> > 
> > 
> > {enter long}
> > 
> > (Fml( "ama") -  LLV( Fml("ama"), 10)) 
> > > (opt1* 
> > ( Stdev( Fml("ama") - Ref(Fml( "ama"),-1) , 20)))
> > 
> > 
> > {enter short}
> > 
> > (HHV( Fml("ama"), 10)- Fml( "ama")) 
> > > (opt1* 
> > ( Stdev( Fml("ama") - Ref(Fml( "ama"),-1) , 20)))
> > -------------------------------------------
> > 
> > The periods in {ama} are set to 10, the periods in the filter are 
> set 
> > to 20. I guess my system is anything else than  overwhelming but 
> for 
> > my excuse please consider:
> > 
> > - I'm Swiss so I have to translate the idea to German
> > - my knowledge of Tradestation code (what I guess the "@" comes 
> from) 
> > is even worse than for MS
> > - after all I tried to code what I understood of Kaufmans ideas
> > 
> > Once coded the system showed profits so my guess was it couldn't 
be 
> > to far from the original thoughts ;-) !
> > 
> > Hope this helps to bring some light to this topic. :-)
> > 
> > 
> > By the way: Grizz, would you mind telling us where that you did 
> find 
> > your code(s)? Thanks a lot!
> > 
> > @ Preston: Thank you very much for sharing your knowledge with me
> > (us). I played with your sample of the AMA that you posted some 
> days 
> > ago. To me it looks great on the chart :-). I then tried it to 
use 
> > with the same system as described above but it didn't show as 
much 
> > profit as mine :-(. That doesn't mean one of them is better or 
> not.  
> > 
> > praktikus 
> > 
> > --- In equismetastock@xxxx, "grizz003" <grizz002@xxxx> wrote:
> > > Praktikus
> > > 
> > > I don't quite understand the buy-sell trigger that you are 
using. 
> > Are 
> > > you using an AMA10 crossover of the AMA20? Or something else? 
> > > 
> > > Many thanks,
> > > Grizz
> > > 
> > > By the way, 
> > > I found an Adaptive Moving Average Binary Wave that looks very 
> > > interesting.. Here it is:
> > > 
> > > {Kaufman's Adaptive Moving Average Binary Wave }
> > > Periods := Input("Time Periods",1,1000, 10);
> > > Direction := CLOSE - Ref(Close,-periods);
> > > Volatility := Sum(Abs(ROC(CLOSE,1,$)),periods);
> > > ER := Abs(Direction/Volatility);
> > > FastSC := 2/(2 + 1);
> > > SlowSC := 2/(30 + 1);
> > > SSC := ER * (FastSC - SlowSC) + SlowSC;
> > > Constant := Pwr(SSC,2);
> > > AMA := If(Cum(1) = periods +1, ref(Close,-1)+ constant * (CLOSE-
 
> ref
> > > (Close,-1)),Prev + constant * (CLOSE - PREV));
> > > FilterPercent := Input("Filter Percentage",0,100,15)/100;
> > > Filter := FilterPercent * Std(AMA - Ref(AMA,-1),Periods);
> > > AMALow := If(AMA < Ref(AMA,-1),AMA,PREV);
> > > AMAHigh := If(AMA > Ref(AMA,-1),AMA,PREV);
> > > If(AMA - AMALow > Filter, 1 {Buy Signal},If(AMAHigh - AMA > 
> > Filter, -
> > > 1 {Sell Signal}, 0 {No_Signal}))
> > > 
> > > 
> > > 
> > > --- In equismetastock@xxxx, "praktikus_ms" <mluescher@xxxx> 
wrote:
> > > > Hi grizz
> > > > 
> > > > Yes that's exactly the same formula I'm using. I got mine 
> > > originally 
> > > > from a book called "New Trading Dimensions" by Florek but I'm 
> not 
> > > > sure at the moment wether it exists in english language or 
> > not.The 
> > > > AMA-Formula I posted earlier was with periods set as 10 
> according 
> > > to 
> > > > the original rules in Kaufmans book "Smarter trading". Also 
the 
> > > > periods for filtering the buy and sell signals is set to 20 
for 
> > the 
> > > > same reason. 
> > > > 
> > > > In my opinion the idea of Kaufman souds quite logical to me 
and 
> > he 
> > > > mentions to only adjust the filter. The worst that you can do 
> to 
> > > such 
> > > > a system is overfitting the whole thing (guess what: I know 
> what 
> > > I'm 
> > > > talking about 'cause I lost "some" money with a system that 
was 
> > > close 
> > > > to the "grail". Unfortunately just in one timeframe - the one 
> it 
> > > was 
> > > > (over)optimised.
> > > > 
> > > > Got MS8.0 Pro on a second computer and I got different 
results 
> > than 
> > > > with 7.02 EOD on the same data. Seems that I have tho check 
> > things 
> > > > like order bias ect. 
> > > > 
> > > > Happy trades
> > > > 
> > > > praktikus
> > > > 
> > > >  
> > > > 
> > > > --- In equismetastock@xxxx, "grizz003" <grizz002@xxxx> wrote:
> > > > > TO: Prakticus
> > > > > 
> > > > > 
> > > > > >For my own small piece of fortune I trade a moving average 
> > > System 
> > > > as 
> > > > > >explained by Perry Kaufman in "Smarter Trading" (the 
> adaptive 
> > > > moving 
> > > > > >average) with European bonds 
> > > > > 
> > > > > Prakticus,
> > > > > I was able find the AMA formula at: 
> > > > > http://www.guppytraders.com/Metastock%20Formulas/formula%
> > > 20index.htm
> > > > > 
> > > > > Is this what you are using with good success?  How are you 
> > using 
> > > > it? 
> > > > > This formula does look impressive...
> > > > > Grizz
> > > > > 
> > > > > {Adaptive Moving Average by Perry Kauffman}
> > > > > {Described in S&C 06/1995 - Metastock ver 6.5 or higher}
> > > > > 
> > > > > Periods := 10;  Direction := CLOSE - Ref(CLOSE,-periods);
> > > > > Volatility := Sum(Abs(ROC(CLOSE,1,$)),periods);
> > > > > ER := Abs(Direction/Volatility);
> > > > > FastSC := 2/(2 + 1);  SlowSC := 2/(30 + 1);
> > > > > SSC := ER * (FastSC - SlowSC) + SlowSC;
> > > > > Constant := Pwr(SSC,2);
> > > > > AMA := If(Cum(1) = periods +1, Ref(CLOSE,-1) + constant * 
> > (CLOSE -
> > >  
> > > > Ref
> > > > > (CLOSE,-1)),
> > > > > PREV + constant * (CLOSE - PREV));
> > > > > AMA;


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Plan to Sell a Home?
http://us.click.yahoo.com/J2SnNA/y.lEAA/jd3IAA/BefplB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/