Wallace,
Here’s
the code I use for CMA channels. Uses a triangular MA for extra smoothing as
per Andrew’s comments. You can replace the TRI with S if you want to use
simple MA for comparison. I generally stick with the fixed percentage channel…as
opposed to Hurst who advocates a fixed absolute width. That bit seems slightly
illogical to me as a higher price usually brings higher absolute volatility. If
you plot the fixed % on a semi-log plot then you will get a fixed width.
Hope it helps.
Andy
--------------
{Centred MA Envelopes
(Triangular)}
{half-span CMA
will highlight desired wavelength}
{further 1.5
factor used due to Tri MA double smoothing}
{odd periods
ensure there is a valid centred reference point.
Achieved by
last line of 'P1' code}
{Periods}
P1:=Input("Highlight/Show
Wavelength =",3,10000,31);
X:=Input("NB,
contains all cycles with WLth less than this",0,0,0);
P1:=P1/2;
P1:=round(P1*1.5);
P1:=LastValue(If(Frac(P1/2)=0,P1+1,P1));
{Other Inputs}
Y:=Input("Envelope
Width Basis [1]#ATRs [2]% [3]price",1,3,2);
Z:=Input("Envelope
Width",0,1000,0.005);
{moving
average}
MA:=Mov(C,P1,TRI);
{envelope
width}
X:=If(Y=1,Z*Mov(ATR(1),P1,S),If(Y=2,MA*Z/100,Z));
{envelopes}
EU:=MA+X;
EL:=MA-X;
{Centre Everything}
PC:=LastValue((P1-1)/2);
CMA:=Ref(MA,PC);
CEU:=Ref(EU,PC);
CEL:=Ref(EL,PC);
CMA;CEU;CEL;
----- Original Message -----
Sent: Wednesday,
December 14, 2005 4:07 AM
Subject: [EquisMetaStock
Group] Hurst
Channel