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

Re: Adaptive Moving Averges



PureBytes Links

Trading Reference Links

You probably have this one.  I might have added a little to it but it
is the same basic code.  Does the same thing.

{from Kaufman, '95, p. 151}{Note: "This code saves the most recent trend turning points as Extlow and Exthigh.
It can then use those points to compare the accumulated change of direciton against the filter and avoid missing
a signal due to a very slow trend change."
fILTER VARIES CONSIDERABLY DEPENDING ON MARKET AND DATA FEED.}
{Modifications by James H. Snowden III 7/01}

Inputs: Period(6),  Price((H+L+C)/3) ;
Vars: Noise(0), Signal(0), Diff(0), EfRatio(0), Extlow(0), Exthigh(0), Smooth(0), Fastend(.666), Slowend(.0645), AMA(0);

{CALCULATE EFFICIENCY RATIO}
Diff = AbsValue(Price - Price[1]);
If (CurrentBar <= Absvalue(Period)) then AMA = Price;
If (CurrentBar >   Absvalue(Period)) then begin
        Signal = AbsValue(Price-Price[Absvalue(Period)]);
        Noise = Summation(Diff, Absvalue(Period));
        EfRatio = IFF(Signal=0,0,Signal/Noise);
        Smooth = Power(EfRatio*(Fastend-Slowend) + Slowend,2);

{ADAPTIVE MOVING AVERAGE}
        AMA = AMA[1] + Smooth*(Price - AMA[1]);
End;

{TREND CHANGE FILTER FROM LAST TURN}
If (AMA >= AMA[1] and AMA[1] < AMA[2]) then
        extlow = AMA[1];
If (AMA <= AMA[1] and AMA[1] > AMA[2]) then
        exthigh = AMA[1];
VALUE2=IFF(AMA>AMA[1],1,-1);

IF AMA=AMA[1] THEN VALUE2=0;
IF VALUE2=1 THEN 
        SETPLOTCOLOR(3,BLUE)
ELSE
        IF VALUE2=-1 THEN 
                SETPLOTCOLOR(3,MAGENTA)
        ELSE
                SETPLOTCOLOR(3,YELLOW);

{TRADING SIGNALS}
If (Currentbar  > Absvalue(period) + 5) then begin  
        Plot1(Exthigh,"Exthigh");
        Plot2(AMA,"AMA");
                Plot3(AMA,"AMA");
                Plot4(extlow,"ExtLow");

end;



Best regards,
  Jimmy Snowden
mailto:jhsnowden@xxxxxxx


Wednesday, February 4, 2004, 6:43:31 PM, you wrote:

c> Hi all

c> Does anybody have any "adaptive moving average" code they are willing to
c> share with me :O) please please please

c> I have a few but would like some more ideas....

c> Any help muchly appreciated :O)
c> Cheers
c> Cameron

c> ---




Outgoing mail scanned by Norton