PureBytes Links
Trading Reference Links
|
On Tue, 30 May 2000 19:40:20 -0400, you wrote:
> I'll take you up on that offer...i am trying to code Kaufmann AMA and
> having a problem getting it to work..I will send you the code if you need
> it to figure out....
Hi Jim,
Expanding on HHP:
====================================================
Adaptive Moving Average - Perry Kauffman, TASC Bonus/1998 Equis
For MetaStock 6.5, Adaptive Moving Average system, akin to VIDYA.
Choose Indicator Builder from the Tools menu and then click on the New
button. Enter the following formulas.
Adaptive Moving Average Binary Wave
Periods := Input("Time Periods",1,1000, 10); {10 is the lookback
period}
{The value "1000" looks very large, 10 as a default seems to make more
sense.
1000 days (bars) correspond to 4 trading years.}
Direction := CLOSE - Ref(Close,-periods);
{"Direction" is nothing but the "periods"-day momentum: the difference
between today's Close and the close periods days ago.}
Volatility := Sum(Abs(ROC(CLOSE,1,$)),periods);
{This is the sum of daily changes (absolut values) of the close prices
over "periods" days (bars).}
ER := Abs(Direction/Volatility); {ER = Efficiency Ratio}
{ER will be between 0 and 1. If the close moves from its current level
in a constant move up to a value periods days later, Direction and
Volatility will be equal (in value), dito for a down move. If the
prices oscillate, and the close is equal to the close periods days
ago, Direction will be 0. As a rule, Volatility will be greater than
Direction. If You take a period of 1 day, then Volatility =
abs(Direction) and ER = 1.}
FastSC := 2/(2 + 1); {2=2 EMA which is the fastest MA in the variable
average basic formula is 2/(n+1)?}
SlowSC := 2/(30 + 1); {30 = 30 EMA is the slowest MA in the variable
average}
SSC := ER * (FastSC - SlowSC) + SlowSC;
{As ER is a value between 0 and 1, You will get as SSC (Smoothed
Scaling Constant? I really don't know) a value between SlowSC and
FastSC. If ER is 0, then SSC is equal to SlowSC, if ER is 1, then SSC
is equal to FastSC. So SSC is a value between 0.66 and 0.0645
(approximately), a range of about 10 to 1.
So an oscillating market corresponds to a slow MA, a trending market
to a fast MA? At a first glance, this does not make sense.}
Constant := Pwr(SSC,2);
{That's SSC squared. Squaring a number smaller than 1 makes it
smaller: Constant is a value between 0.444... and 0.00416, now You
have a range of 100 to 1.}
AMA := If(Cum(1) = periods +1, ref(Close,-1) + constant * (CLOSE -
ref(Close,-1)),Prev + constant * (CLOSE - PREV));
AMA
{The main portion of the formula is "PREV+constant*(close-PREV)": You
take the difference between today's close and yesterdays value of the
AMA, multiply it by Constant and add it to yesterday's AMA (the
difference could be negative). In a trending market, You will take
about 44% of the difference between today's close and PREV, in an
oscillating market 0.4%.
You have to provide a starting value for AMA (to be used as PREV)
hence the term "Ref(CLOSE,-1)+constant*(CLOSE-Ref(CLOSE,-1))", which
is computed after periods+1 days. Before periods days are elapsed,
Direction and Volatility and hence ER are not defined.
The result looks as expected: speeding up in trends long enough
compared to periods, and ignoring oscillations short in comparison to
periods, though they are very strong (but maybe that's the idea behind
AMA?).
It doesn't look very useful to me: Do You have any hints as how to
build trading rules around AMA?
BTW, VIDYA can be indexed to CMO or r-squared.}
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}))
Adaptive Moving Average
Periods := Input("Time Periods",1,1000, 10); {Periods := Input("Time
Periods",1,1000, 20);}
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
If you want to see the adaptive moving average, just plot it on any
chart in MetaStock. If you want to see the buy and sell signals from
the adaptive moving average system, plot the adaptive moving average
binary wave. This binary wave plots a "1" when there's a buy signal, a
"-1" for a sell signal and a zero when there's no signal.
===========================
This is a cut an paste from various messages on this SIG and the TASC
site.
Maybe we could try to place a better subject header. I left it alone
to keet the e-mailer programs consistent with the thread.
-÷ Chris ß ÷-
|