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

Re: [amibroker] Re: MA, DEMA and TEMA can take array parameters, but EMA can't?



PureBytes Links

Trading Reference Links

Dimitris,

You are welcome. By the way, you may be interested in the recent article
in Stocks&Commodities (11/2003) that I have written Traders Tips for.
(http://www.amibroker.com/members/)

The author (Spyros Raftopoulos) presented zig zag validity technique very similar to one that you have presented
months ago on AmiBroker mailing list.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, October 15, 2003 10:38 PM
Subject: [amibroker] Re: MA, DEMA and TEMA can take array parameters, but EMA can't?


> Tomasz,
> thank you for the explanations [and the interesting ref].
> I have no misunderstanding about the recursive mechanism of AMA etc.
> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <amibroker@xxxx> 
> wrote:
> > Dimitris,
> > 
> > Yes we can call them equivalent because Wilders( array, 1/x) 
> function uses
> > exactly the same formula as AMA( array, 1/ x):
> > 
> > WildersToday = ( Array + ( Periods - 1 ) * WildersYesterday ) / 
> Periods.
> > 
> > This is mathematically strictly the same as:
> > 
> > WildersToday = Array * ( 1/ Periods )  + (1 - (1/Periods) ) * 
> WildersYesterday;
> > 
> > Now AMA is:
> > 
> > AMAToday = Array * Factor + (1-Factor) * AMAYesterday
> > 
> > When Factor = 1/periods those two are mathematically strictly 
> equivalent.
> > 
> > There is no magic, just pure math.
> > 
> > It does not really matters if Factor is variable or not because the 
> formula
> > is constant.
> 
> This is exactly my point : A formula may be constant [the same] but 
> the procedure may be meaningless.
> The y=x^2-2 is well defined in integers, rationals and real numbers, 
> the solution of x^2-2=0 is N/A for integers or rationals.
> We may have, in AFL, variable per for MA(C,per), but what is the 
> meaning ?
> The definition of a 10-bar MA is
> MA(C,10)=sum(C,10)/10
> After this, the MA(C,9.3) is meaningless.
> Now, if we make an internal agreement and "define" for every x, 
> 9<=x<10 the MA(C,x) equal to MA(C,9), then we say that we have 
> variable MA but it is not true, it does not fit to the definition of 
> MA.
> So, before looking at the maths, we have to give some meaning to this 
> variable period for Wilders, EMA etc.
> This is my point, if a variable per MA, EMA exists or not.
> We can not transfer in T/A the continuous functions without some 
> special [and usually not declared] agreement, T/A time is not 
> continuous, the beatiful continuous lines we see are nothing but 
> illusions, the real thing is discrete dots without the intermediate 
> points. You, as a creator, use a special technique to give us 
> these "continuous" lines. And you need this technique, because your 
> initial material is discontinuous [and a bit ugly...].
> The continuous lines we see in an RSI graph is not a proof that our 
> RSI arrays are continuous and it should be clear.
> Thank you for the interesting dialogue, I will revert when you 
> implement the variable period EMA in some future AFL edition.
> Now, it would be better to come back to the final tests of the most 
> interesting Equity Inspection Points application.
> Dimitris Tsokakis
> 
> > You are making false assumption thinking that
> > 
> > evenbar = BarIndex()%2 == 0;
> > 
> > AMA( C, IIF( evenbar, 10, 11 ) ) 
> > 
> > will work like
> > 
> > IIF( evenbar, AMA( C, 10 ), AMA( C,11 ) )
> > 
> > but this is just that - false assumption. You assume that
> > switching periods would cause all calculations to start from the 
> very beginning,
> > but it is not the case. 
> > As for analogy: it is well known thing in electroacustics.
> > 
> > The EMA (AMA, etc) is single pole recursive low pass filter aka
> > as infinite impulse response filter (IIR)
> > 
> http://www.ece.utexas.edu/~bevans/courses/realtime/lectures/06_IIR_Fil
> ters/lecture6.pdf
> > 
> > 
> > If you have PHYSICAL single pole low pass filter (for example 
> simple RC or LC circuit) and you change
> > the 'cut-off' frequency (by changing capacity of condenser for 
> example) 
> > then you are not able to 'start from the beginning'
> > because physical filter has it's state and if you change
> > the parameters these parameters are applied to current state.
> > This is *exactly* how variable period AMA works.
> > AMA and others work in 'real time'. They preserve its state 
> (previous value of AMA)
> > and apply parameters (smoothing factor) to produce next value. 
> Exactly like physical circuit.
> > Physical RC circuit can not go back and take the series voltage 
> numbers from past year to calculate
> > todays value. It just remembers its current state.
> > Exactly the same AMA - all it needs is CURRENT data (price) and its 
> previous state (single number
> > representing previous value of AMA). It does not re-start 
> calculations from the very beginning, ever.
> > 
> > And this is fundamentally different from FIR filter (Finite impulse
> > response) like MA that is re-calculated for N-bars, not for 
> infinite number of bars.
> > 
> > Best regards,
> > Tomasz Janeczko
> > amibroker.com
> > ----- Original Message ----- 
> > From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx>
> > To: <amibroker@xxxxxxxxxxxxxxx>
> > Sent: Wednesday, October 15, 2003 2:47 PM
> > Subject: [amibroker] Re: MA, DEMA and TEMA can take array 
> parameters, but EMA can't?
> > 
> > 
> > > Tomasz,
> > > I clearly understand the recursive nature of these functions.
> > > This is not the subject.
> > > The question is : Can we call "equivalent" two never touching 
> lines ?
> > > It is somehow tricky to ask from the user to accept the following 
> > > story:
> > > 1. Wilders(C,x) is N/A for  variable x  
> > > 2. For fixed x the Wilders(C,x)=AMA(C,1/x) is true
> > > 3. Please accept the "analog" meaning for the argument
> > > Arg. 1 : Wilders(C,x) is *also* AMA(C,1/x) *even when* x is 
> variable
> > > or
> > > Arg. 2 : You may call AMA(C,1/x) as Wilders(C,x), x variable, 
> > > *because* AMA(C,1/x) *is* Wilders(C,x), when x=fixed !!
> > > 
> > > We have no evidence that this "analogy" exists and, form my 
> experiece 
> > > in Physics, it is dangerous to speak [and use] for analogies just 
> > > because we like them. 
> > > >From this point of view, it is better not to have variable 
> periods 
> > > for EMA, Wilders. Now, AMA(C,1/x) , 10<=x<=20 is an interesting 
> > > line "between" AMA(C,1/10) and AMA(C,1/20) and this could be the 
> > > happy end of the story. If someone needs to call it Wilders with 
> > > variable period, it is OK, but there is no evidence to do it.
> > > Dimitris Tsokakis
> > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
> <amibroker@xxxx> 
> > > wrote:
> > > > Dimitris,
> > > > 
> > > > The explanation should be obvious to someone with the deep 
> > > background
> > > > in physics and mathematics as you.
> > > > 
> > > > The reason is that AMA, EMA, TEMA, DEMA, Wilders
> > > > are all recursive functions. See
> > > > http://www.amibroker.com/guide/afl/afl_view.php?name=AMA
> > > > and
> > > > http://www.amibroker.com/guide/afl/afl_view.php?name=DEMA
> > > > 
> > > > for detailed recursive algorithm.
> > > > 
> > > > What does it mean? It means that current value depends
> > > > on input data array and PREVIOUS value of the indicator.
> > > > The PREVIOUS value includes the value of "previous-previous" 
> value
> > > > and so on. 
> > > > Now if you change the period every bar all these changes (for 
> all 
> > > previous bars)
> > > > affect current bar value and that's why variable period AMA is 
> > > smooth and
> > > > does not jump from Wilders10-Wilders11.
> > > > 
> > > > Best regards,
> > > > Tomasz Janeczko
> > > > amibroker.com
> > > > ----- Original Message ----- 
> > > > From: "DIMITRIS TSOKAKIS" <TSOKAKIS@xxxx>
> > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > Sent: Wednesday, October 15, 2003 1:36 PM
> > > > Subject: [amibroker] Re: MA, DEMA and TEMA can take array 
> > > parameters, but EMA can't?
> > > > 
> > > > 
> > > > > Tomasz,
> > > > > How do we understand this equivalence ?
> > > > > x=10+(Cum(1)%11);  
> > > > > is equal to 10 every 11 bars.
> > > > > The
> > > > > Wp=10;Plot(Wilders(C,Wp),"Wilders",1,1);
> > > > > and
> > > > > Plot(AMA(C,1/x),"AMA",7,8);
> > > > > do not touch every 11 bars...
> > > > > The same with Wilders(c,20).
> > > > > See, for example the
> > > > > 
> > > > > x=10+(Cum(1)%11);  
> > > > > Wp10=10;Plot(Wilders(C,Wp10),"Wilders10",1,1);
> > > > > Wp20=20;Plot(Wilders(C,Wp20),"Wilders20",1,1);
> > > > > Plot(AMA(C,1/X),"AMA",7,1);
> > > > > Plot(AMA(C,1/10),"AMA 1/10",4,8);
> > > > > Plot(AMA(C,1/20),"AMA 1/20",4,8);
> > > > > 
> > > > > AMA(C,1/10) is 1-1 equivalent to Wilders(C,10).
> > > > > On the other side, AMA(C,1/X) touches only by coincidence the 
> > > Wp10 or 
> > > > > Wp20.
> > > > > 
> > > > > Dimitris Tsokakis
> > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
> > > <amibroker@xxxx> 
> > > > > wrote:
> > > > > > Stephane,
> > > > > > 
> > > > > > That's true but Wilders is nothing more nothing less than 
> just 
> > > AMA
> > > > > > with 1/n smoothing factor.
> > > > > > 
> > > > > > Wilders( array, N )  =>>>  AMA( array, 1 / N )
> > > > > > 
> > > > > > 
> > > > > > Best regards,
> > > > > > Tomasz Janeczko
> > > > > > amibroker.com
> > > > > > ----- Original Message ----- 
> > > > > > From: "Stephane Carrasset" <nenapacwanfr@xxxx>
> > > > > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > > > > Sent: Wednesday, October 15, 2003 1:03 PM
> > > > > > Subject: [amibroker] Re: MA, DEMA and TEMA can take array 
> > > > > parameters, but EMA can't?
> > > > > > 
> > > > > > 
> > > > > > > Hi, Dimitri,
> > > > > > > 
> > > > > > > Wilders does not accept variable period
> > > > > > > 
> > > > > > > Plot(Wilders(C,RSI(3)),"",2,1);
> > > > > > > 
> > > > > > > return a bad argument
> > > > > > > 
> > > > > > > stepghane
> > > > > > > 
> > > > > > > 
> > > > > > > <nenapacwanfr@xxxx> wrote:
> > > > > > > > Dimitri,
> > > > > > > > 
> > > > > > > > I didn't know that wilders accept variable period...
> > > > > > > > Thanks
> > > > > > > > 
> > > > > > > > Stephane
> > > > > > > > 
> > > > > > > > > Dave,
> > > > > > > > > I have posted in the files section the varPER.txt 
> with 
> > > the 
> > > > > EMA, 
> > > > > > > AMA 
> > > > > > > > > and WILDERS smoothing relations.
> > > > > > > > > AMA and WILDERS do accept variable periods, like MA.
> > > > > > > > > You will also find some RSI applications there.
> > > > > > > > > Dimitris Tsokakis
> > > > > > > > > --- In amibroker@xxxxxxxxxxxxxxx, "Dave Merrill" 
> > > > > <dmerrill@xxxx> 
> > > > > > > > > wrote:
> > > > > > > > > > thanks, much appreciated. seems like there's a new 
> > > version 
> > > > > just 
> > > > > > > > out 
> > > > > > > > > too (:-)
> > > > > > > > > > 
> > > > > > > > > > any chance of variable period RSI, CCI, ROC and the 
> > > rest of 
> > > > > the 
> > > > > > > AB
> > > > > > > > > > indicators I'm forgetting right now? some of these 
> I've 
> > > > > coded 
> > > > > > > up 
> > > > > > > > > myself in
> > > > > > > > > > AFL, but they're much slower than the built in 
> > > versions. 
> > > > > I'd 
> > > > > > > > > imagine your
> > > > > > > > > > dll would be pretty close to built in speed, yes?
> > > > > > > > > > 
> > > > > > > > > > dave
> > > > > > > > > >   In Indicators.dll varperiod Indicators are
> > > > > > > > > >   Stochastic
> > > > > > > > > >   GraphXSpace=1;
> > > > > > > > > >   Plot(StochK(9,1),"",colorBlue,1);
> > > > > > > > > >   Plot(scStoch(9),"",colorGreen,1+8);
> > > > > > > > > >   Plot(scStoch(RSI(14)),"",colorRed,1);
> > > > > > > > > > 
> > > > > > > > > >   Ema
> > > > > > > > > >   Plot(EMA(C,21),"",colorBlue,1);
> > > > > > > > > >   Plot(scEMA(C,21),"",colorGreen,1+8);
> > > > > > > > > >   Plot(scEMA(C,RSI(14)),"",colorRed,1);
> > > > > > > > > >   Plot(C,"",1,64);
> > > > > > > > > > 
> > > > > > > > > >   Linregslope
> > > > > > > > > >   Plot(LinRegSlope(C,21),"",colorBlue,1);
> > > > > > > > > >   Plot(scLinRegSlope(C,21),"",colorGreen,1+8);
> > > > > > > > > >   Plot(scLinRegSlope(C,RSI(14)),"",colorRed,1);
> > > > > > > > > > 
> > > > > > > > > >   MFI // just added today
> > > > > > > > > >   Plot(MFI(21),"",colorBlue,1);
> > > > > > > > > >   Plot(scMFI(21),"",colorGreen,1+8);
> > > > > > > > > >   Plot(scMFI(RSI(14)),"",colorRed,1);
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > >   > thanks stephane, I'll take a look. until I do, 
> can 
> > > you 
> > > > > tell 
> > > > > > > > me 
> > > > > > > > > if
> > > > > > > > > >   it also
> > > > > > > > > >   > contains variable period versions of other 
> built in 
> > > AB 
> > > > > > > > > indicators?
> > > > > > > > > >   other
> > > > > > > > > >   > than allowing variable periods, do they perform 
> the 
> > > > > same as 
> > > > > > > > the
> > > > > > > > > >   native
> > > > > > > > > >   > versions? if so, that'd be a nice workaround 
> until 
> > > > > variable 
> > > > > > > > > periods
> > > > > > > > > >   are a
> > > > > > > > > >   > native AB capability for everything.
> > > > > > > > > >   >
> > > > > > > > > >   > dave
> > > > > > > > > >   >   if you want, in indicators.dll there is a Ema 
> > > with 
> > > > > > > variable 
> > > > > > > > > period
> > > > > > > > > >   >
> > > > > > > > > >   >   Plot(scEMA(C,RSI(14)),"",colorRed,1);
> > > > > > > > > >   >   Plot(C,"",1,64);
> > > > > > > > > >   >
> > > > > > > > > >   >
> > > > > > > > > >   >   stephane
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > >         Yahoo! Groups Sponsor
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > >   Send BUG REPORTS to bugs@xxxx
> > > > > > > > > >   Send SUGGESTIONS to suggest@xxxx
> > > > > > > > > >   -----------------------------------------
> > > > > > > > > >   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 the 
> Yahoo! 
> > > Terms 
> > > > > of 
> > > > > > > > > Service.
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > Send BUG REPORTS to bugs@xxxx
> > > > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > > > -----------------------------------------
> > > > > > > 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/ 
> > > > > > > 
> > > > > > > 
> > > > > > >
> > > > > 
> > > > > 
> > > > > 
> > > > > Send BUG REPORTS to bugs@xxxx
> > > > > Send SUGGESTIONS to suggest@xxxx
> > > > > -----------------------------------------
> > > > > 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/ 
> > > > > 
> > > > > 
> > > > >
> > > 
> > > 
> > > 
> > > Send BUG REPORTS to bugs@xxxx
> > > Send SUGGESTIONS to suggest@xxxx
> > > -----------------------------------------
> > > 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/ 
> > > 
> > > 
> > >
> 
> 
> 
> 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 ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/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/