PureBytes Links
Trading Reference Links
|
Hi Jose
> "However on bar two it makes a lot of sense to use 75% of the value
> from bar one and add that to 25% of the value of bar two."
>
> Exponential Moving Averages are weighted towards the latest data.
> The above logic places the majority of the weight on the previous bar.
You're right about the weighting and I'm right about about the proportions. One each.
> "Personally I think that starting the EMA at zero would be a nonsense,
> and seeding with the bar one data array value is exactly the way it
> should be."
>
> I prefer to think that any average needs at least two values to
> compute. There can be no average for bar one.
The average of one bar is not only possible but very precise, and easy to calculate too. MetaStock
and I agree :-)
> Compare the EMA plot below on the first seven bars of any chart:
Your EMA varies from the MetaStock EMA for quite a few bars after the first seven as well. Is that
right or wrong, or just different?
Regards
Roy
> ===
> EMA
> ===
> ---8<--------------------
>
> { Exponential Moving Average v2.0 }
> { EMA periodicity shortens on low bar count }
> { ©Copyright 2003 Jose Silva }
> { http://users.bigpond.com/prominex/pegasus.htm#metastock }
>
> pds:=Input("EMA periods",1,2520,7);
> x:=Input("use Open=1 High=2 Low=3 Close=4 Volume=5 P=6",1,6,4);
> shift:=Input("EMA vertical shift %",
> -100,100,0)/100+1;
> plot:=Input("EMA=1, Crossover signals=2",1,2,1);
>
> x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C)))));
> pds:=If(pds>Cum(x<>-101),Cum(x<>-101),pds);
> Ema:=x*2/(pds+1)+PREV*(1-2/(pds+1));
> Ema:=Ema*shift;
> signals:=Cross(x,Ema)+-Cross(Ema,x);
>
> If(plot=2,signals,Ema)
>
> ---8<--------------------
>
>
> jose '-)
>
>
>
>
>
> --- In Metastockusers@xxxxxxxxxxxxxxx, "Roy Larsen" <rlarsen@xxxx>
> wrote:
> > Ron, Larry
> >
> > MS does indeed "seed" an EMA with the first data point as in the
> following example..
> >
> > {Exponential Moving Average}
> > n:=Input("Periods",1,999,7);
> > R:=2/(n+1); {ratio of new data added each bar}
> > M:=If(Cum(1)=1,C,PREV*(1-R)+C*R);
> > M;
> >
> > Failure to do so will give a severely distorted plot at the
> beginning of the EMA as per this code..
> >
> > {Exponential Moving Average}
> > n:=Input("Periods",1,999,7);
> > R:=2/(n+1); {ratio of new data added each bar}
> > M:=PREV*(1-R)+C*R;
> > M;
> >
> > It makes perfect sense to me that it should be done the way it is,
> though I see no reason for MS
> > inhibiting the plot (canned version) until the specified number of
> periods have passed. In this
> > function the "periods" value is only a convenient way of expressing
> the proportions of old data
> > retained and new data added on each bar - it has little relevance to
> actual periods.
> >
> > A "seven period" EMA will add 25% of new data and retain 75% of old
> data on each bar. Any variable
> > using PREV cannot plot on bar one for the obvious reason that there
> is no available previous bar of
> > data. However on bar two it makes a lot of sense to use 75% of the
> value from bar one and add that
> > to 25% of the value of bar two. If the EMA is not seeded with the
> value of bar one the result from
> > bar two will be zero (PREVious value of EMA) plus 25% of bar the bar
> two value.
> >
> > Personally I think that starting the EMA at zero would be a
> nonsense, and seeding with the bar one
> > data array value is exactly the way it should be.
> >
> > Roy
> >
> >
> > ----- Original Message -----
> > From: "Ron" <ronber@xxxx>
> > To: <DEFANGED_Metastockusers@xxxxxxxxxxxxxxx>
> > Sent: Monday, May 10, 2004 8:54 AM
> > Subject: Re: [Metastockusers] Exponential Moving Average in Excel
> >
> >
> > > I looked more closely at the values. It appears that what MS is
> doing is
> > > taking the first data point and treating it as though it was the
> simple
> > > average (i.e. start point) and then calculates EMAs based on that
> point.
> > > However, it only displays data starting with the 5th day. That
> method
> > > will lead to a small difference in the two methods.
> > >
> > >
> > > Ron wrote:
> > >
> > > > Larry,
> > > >
> > > > I ran a tiny experiment. I loaded only the number of days data
> in MS
> > > > that I was going to use for my calculation in Excel. Then copied
> and
> > > > pasted the MS data into Excel. The EMA numbers were the same to
> 4
> > > > decimal places when I did that.
> > > >
> > > > Ron
> > > >
> > > >
> > > > Ron wrote:
> > > >
> > > >>Larry,
> > > >>
> > > >>I'm guessing the issue is the starting point.
> > > >>
> > > >>The numbers will be different depending on from where the moving
> average
> > > >>is calculated (started) which is dependent on the days loaded in
> MS. You
> > > >>can see this for yourself by applying an EMA to a ticker, then
> note the
> > > >>value for the most recent date when you have very few days
> loaded vs.
> > > >>the value when you have many more days loaded.
> > > >>
> > > >>I believe the numbers should match up, if they are fed exactly
> the same
> > > >>data.
> > > >>
> > > >>Try loading only the most recent 10 days in MS (those are the
> days on
> > > >>which you're basing your Excel calculation) and see if the
> numbers match
> > > >>up then.
> > > >>
> > > >>Ron
> > > >>
> > > >>lseldin wrote:
> > > >>
> > > >>
> > > >>
> > > >>>Ron,
> > > >>>
> > > >>>I was able to get your spreadsheet from Yahoo files.
> > > >>>
> > > >>>I am not getting the same results from MetaStock.
> > > >>>
> > > >>>My data file has these inputs:
> > > >>>
> > > >>>Close EMA PERIODS 5
> > > >>>1098.7 EXPONENT 0.333333333
> > > >>>1113.98999 1-Exponent 0.666666667
> > > >>>1121.530029
> > > >>>1119.550049
> > > >>>1117.48999 1114.252012 Starts with 5 period SMA
> > > >>>1107.300049 1111.934691
> > > >>>1113.890015 1112.586465
> > > >>>1122.410034 1115.860988
> > > >>>1138.109985 1123.277321
> > > >>>1135.530029 1127.361557
> > > >>>
> > > >>>If I am reading your spreadsheet correct, your MA exp (5) is:
> > > >>>1127.36
> > > >>>
> > > >>>MetaStock says 5 period EXP is: 1111.51
> > > >>>MetaStock says 10 period EXP is: 1116.99
> > > >>>
> > > >>>Can you help me get the numbers to match?
> > > >>>
> > > >>>Thanks for your patience.
> > > >>>
> > > >>>larryTAKEOUT@xxxx
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>Yahoo! Groups Links
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>Yahoo! Groups Links
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >>
> > > >
> > > >
> > > > Yahoo! Groups Sponsor
> > > > ADVERTISEMENT
> > > > click here
> > > >
> > <http://rd.yahoo.com/SIG=12944tktg/M=285832.4851039.5997748.
> 1269404/D=groups/S=1705001779:HM/EXP=108
> > 4221428/A=2105440/R=0/SIG=14dpdlr1u/*http://www.householdfinance.
> com/ln/TrackingServlet?cmd_MediaCod
> >
> e=&fc=APS&mkt=000&mc=01PSYAYA004001B220000U0300L0010000000000&dest=HOM
> E_PAGE>
> > > >
> > > >
> > > >
> > > >
> ----------------------------------------------------------------------
> --
> > > > Yahoo! Groups Links
> > > >
> > > > * To visit your group on the web, go to:
> > > > http://groups.yahoo.com/group/Metastockusers/
> > > >
> > > > * To unsubscribe from this group, send an email to:
> > > > Metastockusers-unsubscribe@xxxxxxxxxxxxxxx
> > > > <mailto:Metastockusers-unsubscribe@xxxxxxxxxxxxxxx?
> subject=Unsubscribe>
> > > >
> > > > * Your use of Yahoo! Groups is subject to the Yahoo! Terms
> of
> > > > Service <http://docs.yahoo.com/info/terms/>.
> > > >
> > > >
> > >
> > >
> >
> >
> >
> ----------------------------------------------------------------------
> ----------
> >
> >
> > > I looked more closely at the values. It appears that what MS is
> doing is taking the first data
> > point and treating it as though it was the simple average (i.e.
> start point) and then calculates
> > EMAs based on that point. However, it only displays data starting
> with the 5th day. That method will
> > lead to a small difference in the two methods.
> > >
> > >
> > > Ron wrote:
> > >
> > > Larry,
> > >
> > > I ran a tiny experiment. I loaded only the number of days data
> in MS that I was going to use for
> > my calculation in Excel. Then copied and pasted the MS data into
> Excel. The EMA numbers were the
> > same to 4 decimal places when I did that.
> > >
> > > Ron
> > >
> > >
> > > Ron wrote:
> > >
> > > Larry,
> > >
> > > I'm guessing the issue is the starting point.
> > >
> > > The numbers will be different depending on from where the moving
> average
> > > is calculated (started) which is dependent on the days loaded in
> MS. You
> > > can see this for yourself by applying an EMA to a ticker, then
> note the
> > > value for the most recent date when you have very few days loaded
> vs.
> > > the value when you have many more days loaded.
> > >
> > > I believe the numbers should match up, if they are fed exactly the
> same
> > > data.
> > >
> > > Try loading only the most recent 10 days in MS (those are the days
> on
> > > which you're basing your Excel calculation) and see if the numbers
> match
> > > up then.
> > >
> > > Ron
> > >
> > > lseldin wrote:
> > >
> > > Ron,
> > >
> > > I was able to get your spreadsheet from Yahoo files.
> > >
> > > I am not getting the same results from MetaStock.
> > >
> > > My data file has these inputs:
> > >
> > > Close EMA PERIODS 5
> > > 1098.7 EXPONENT 0.333333333
> > > 1113.98999 1-Exponent 0.666666667
> > > 1121.530029
> > > 1119.550049
> > > 1117.48999 1114.252012 Starts with 5 period SMA
> > > 1107.300049 1111.934691
> > > 1113.890015 1112.586465
> > > 1122.410034 1115.860988
> > > 1138.109985 1123.277321
> > > 1135.530029 1127.361557
> > >
> > > If I am reading your spreadsheet correct, your MA exp (5) is:
> > > 1127.36
> > >
> > > MetaStock says 5 period EXP is: 1111.51
> > > MetaStock says 10 period EXP is: 1116.99
> > >
> > > Can you help me get the numbers to match?
> > >
> > > Thanks for your patience.
> > >
> > > larryTAKEOUT@xxxx
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Metastockusers/
<*> To unsubscribe from this group, send an email to:
Metastockusers-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|