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

Re: [amibroker] Previous Value



PureBytes Links

Trading Reference Links

Tomasz:

My point in sharing that code was not to provide a AMA but to show how to 
do the 'previous' thing in VBScript. I wanted an easy example that would 
not clutter up the essential part I wanted to show and the moving average 
was it.

Just a note.

Steve

At 08:46 AM 6/20/01 +0200, you wrote:
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

----- Original Message -----
From: <mailto:slwiserr@x...>Steve Wiser
To: <mailto:amibroker@xxxxxxxxxxxxxxx>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.

Steve







  • References: