PureBytes Links
Trading Reference Links
|
Hi Jeff and Steve,
Yes, you can do it in VBSctipt and JScrtipt but there is also
much easier and faster way
of calculating any kind of variable-weight (adaptive) moving
average using
AMA function :
AMA - adaptive moving average
(AFL 1.5)
SYNTAX
ama( ARRAY, SMOOTHINGFACTOR )
RETURNS
ARRAY
FUNCTION
calculates adaptive moving average - simliar to EMA()but
smoothing factor could be time-variant (array).
EXAMPLE
The example of volatility-weighted adaptive moving average formula:
graph0 = ema( close, 15 );fast = 2/(2+1);slow =
2/(30+1);dir=abs(close-ref(close,-10));vol=sum(abs(close-ref(close,-1)),10);ER=dir/vol;sc
=( ER*(fast-slow)+slow)^2;
graph0 = ama( close, sc );
AMA works like this (pseudo-code):
// for day "i" the value is:
movavg[ i ] = smoothingfactor * array[ i ] + ( 1 - smoothingfactor ) *
movavg[ i - 1 ];
// movavg[ i - 1 ] is a PREVIOUS day value of movavg
There is also a second version of AMA called AMA2 when you get
3 parameters:
AMA2( Array, ForwardFactor, FeedbackFactor ) and is equivalent
to this pseudo-code
// for day "i" the value is:
movavg[ i ] = forwardfactor * array[ i ] + feedback * movavg[ i -
1 ];
// movavg[ i - 1 ] is a PREVIOUS day value of movavg
Best regards,
Tomasz Janeczko
<BLOCKQUOTE dir=ltr
>
----- Original Message -----
<DIV
>From:
Steve Wiser
To: <A title=amibroker@xxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Wednesday, June 20, 2001 12:36
AM
Subject: Re: [amibroker] Previous
Value
Jeff:This has been done using VBScript a couple of
times once as an example and another as a tool for an indicator.See
the attached file as an example.SteveAt 03:29PM
6/19/01 -0400, you wrote:>Hello to All!>>Just got the
lastest issure of Active Trader Magazine....always like to >play around
with the systems they present in "The Trading Systems Lab"
>section...>>This month they present a system based on a
Volume Weighted Moving >Average. Everything is fairly simpleto
code into AFL, with one little >exception...to start the calculation of
the VWMA you must have the >"previous" VWMA to preform the calculation.
There is my problem...how to >get a "previous" value of an array when
you haven't preformed the first >calculation of the
array.>>All you "Codies" out there...any
suggestions?>>Thanks>>JeffYour
use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
|