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

Re: [amibroker] Custom EMA with Decay Factor



PureBytes Links

Trading Reference Links

Anthony,

I don't know what was your original idea - it is hard to guess from this code,
but "custom" exponential smoothing in AFL
is much easier to implement using
AMA and AMA2 functions:

AMA( array, factor )

internally implements

ama[ i ] = factor[ i ] * array[ i ] + ( 1 - factor[ i ] ) * array[ i - 1 ];

or using simplyfied syntax:
ama( today ) = factor * array + ( 1 - faactor ) * ama( previous bar );


Best regards,
Tomasz Janeczko
===============
AmiBroker - the comprehensive share manager.
http://www.amibroker.com

----- Original Message -----
From: "Anthony Faragasso" <ajf1111@xxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, November 11, 2001 5:41 PM
Subject: [amibroker] Custom EMA with Decay Factor


> Tomasz;
>
> Could you check out this code, to see if I have satisfied the calls. I
> have included the excel spreadsheet with the formulas.
>
> Also, does this custom EMA warrant any discussion, This is the first
> time I have seen a Decay Factor added.
> Maybe Dimitri can evaluate.
>
> Thank you
> Anthony
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


--------------------------------------------------------------------------------


> /* Custom Exponential Moving Average */
> /* with Decay Factor, coded by Anthony Faragasso*/
>
> MaxGraph=8;
>
> pds=10; /* Custom EMA periods,and EMA standard, you can change period*/
> pds2=10;/* Simple MA periods , you can change period*/
>
> Smooth=(2/(pds+1));
> Decay=(1-smooth);
>
> /* set the P variable: O,H,L,C , your average can be on any price variable */
> P=C;
>
> P1=p;
> Avg2=(Smooth*p)+(Decay*p1);/* this line should read (smooth*p)+(decay*ema.prev)*/
>
> Avg3=EMA(Avg2,pds);
>
> Avg4=(Smooth*p)+(Decay*Ref(Avg3,-1));/* have I satisfied that line Here*/
>
> Graph0=EMA(Avg4,pds);
> Graph0Color=6;
> Graph0Style=1; /* blue line , Custom EMA with Decay*/
>
> Graph2=C;
> Graph2Style=128;
>
> Graph3=MA(p,pds2);
> Graph3Color=4; /*red line , Simple MA */
>
> Graph4=EMA(p,pds);
> Graph4Color=2; /* white line , EMA standard */
>
> Title=Name()+" Custom EMA with Decay :Blue "+"("+WriteVal(Graph0,format=1.2)+")"+" EMA
:White"+"("+WriteVal(Graph4,format=1.2)+")"+" Simple MA :Red "+"("+WriteVal(Graph3,format=1.2)+")"+" Close
:"+"("+WriteVal(Graph2,format=1.2)+")";