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

[amibroker] Re: Built-in DEMA questions



PureBytes Links

Trading Reference Links

Dimitris,

I believe TJ is saying that with a 200 bar EMA it will take 600 bars 
to be the same or 2 * Len AFTER the initial 200 bars.

If you are wanting an equivalent calculation to the built in DEMA use 
AMA instead of EMA in your formula and of course change the period to 
a factor i.e. factor = 2 / ( Length + 1 ).  I think you'll see that 
this is identical to DEMA from the beginning.

--- In amibroker@xxxxxxxxxxxxxxx, "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx> 
wrote:
> --- 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


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading!
Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/cjB9SD/od7FAA/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/