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

Re: [amibroker] Re: Built-in DEMA questions



PureBytes Links

Trading Reference Links

Dimitris,

As to your question of when and how close they will converge.

200 bar moving average is
factor = 2/(200+1) = 0.00995

EMA( today ) = ARRAY * 0.00995 + ( 1- 0.00995 ) * EMA( yesterday ).

After initialization with MA every next bar of EMA
contains (1-0.00995) = 99.005% part of its initial value.
Therefore initial difference after 200 bars will be attentuated
down to 

(1 - 0.00995)^200 = 0.1353 = 13.53% of its initial value

and after 400 bars will be attentuated down to:

(1 - 0.00995)^400 = 0.018317 = 1.83% of its initial value.

So we can say that initial distance between DEMA( 200 ) and
DEMA( 200 ) re-implemented using EMA shinks down to 1.8%
of initial value after 400 bars after EMA initial value (the 200-th bar).

Since initial distance between these two usually is somewhere
near 10% the final distance at 600th bar (400+200) is
0.1 * 0.018  = 0.0018 = 0.18%.

I think with less than 0.18% distance we can say they converged. 

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Sunday, April 27, 2003 9:15 PM
Subject: [amibroker] Re: Built-in DEMA questions


> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
> wrote:
> > Dimitris,
> > 
> > 
> > > > 
> > > > Not really. By definition DEMA and all exponential moving 
> averages 
> > > because of their recursive formula,
> > > > require only 2 (EMA) or 3 bars (DEMA/TEMA) to calculate first 
> value.
> > > > But it just the convention that first 2 * len periods are being 
> > > considered as "not accurate".
> > > 
> > > Tomasz,
> > > OK for the first 2*len periods. Is it accurate for the next 2*len 
> > > periods?
> > > Is it accurate for the next 4*len periods ?
> > > What is accurate for you ? 10% divergence, 1% divergence, 0.01% 
> > > divergence ?
> > > If the final amibroker use is to trade, a cross(X,20) is *very 
> > > different* from a cross(X,21) in a [15, 40] scale.
> > 
> > Please see the reply I have just sent to your other post.
> > Because of the fact that EMA and DEMA are INITIALIZED differently
> > it needs 2 * len bars for DEMA re-implemented using EMA
> > to converge with built-in DEMA.
> > After this initial stage they are the same.
> Tomasz,
> for len=200 your explanation means that after the 400th bar built-in 
> DEMA and EMA-equivalent "are the same.
> Did I understand well ?
> In my gifs there is no match after the 400th bar.
> Do we see the same gifs ?
> Dimitris Tsokakis
> 
> 
> 
> 
> > 
> > As Fred wisely pointed out AMA-reimplemented DEMA is the same
> > from the start because it is initialized the same way as DEMA.
> > (Initial value is the first value of input array).
> > 
> > As you probably know all exponential-smoothers are recursive.
> > It means that they take one (or more) previous value(s) of itself
> > to calculate todays value.
> > EMA is simply
> > 
> > factor = 2 / ( periods + 1 );
> > 
> > EMA( today ) = ARRAY( today ) * factor + (1 - factor ) * EMA( 
> yesterday ).
> > 
> > This EMA( yesterday) is just previous value of EMA.
> > So we have go recurrency here.
> > The problem is that at BAR ZERO you don't have any PREVIOUS value.
> > You have to initialize somehow.
> > 
> > One approach is to use ARRAY( 0 ) as initial value of EMA
> > 
> > EMA( 0 ) = ARRAY( 0 )
> > 
> > This approach is used by DEMA, TEMA, AMA, AMA2
> > 
> > Second approach is to initialize EMA( periods ) by simple moving 
> average
> > and start calculations from periods + 1:
> > 
> > for all bar < periods EMA( bar ) = NULL
> > 
> > EMA( periods ) = MA( periods )
> > 
> > for all bars > periods
> > EMA( bar ) = ARRAY( bar ) * factor + (1 - factor ) * EMA( bar - 1 ).
> > 
> > In English: at bar = periods we initialize EMA with simple moving 
> average value because
> > it is not recurrent. Then we continue usual EMA recursive 
> calculation.
> > 
> > This method is used by EMA to match Metastock  way of calculation 
> of EMA
> > (requested by numerous users)
> > 
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> 
> 
> 
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 
>

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/O10svD/Me7FAA/AG3JAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/