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

Re: [Metastockusers] Exponential Moving Average in Excel



PureBytes Links

Trading Reference Links

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@xxxxxxxxxxxxx>
To: <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@xxxxxxxxxx
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>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=HOME_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@xxxxxxxxxx
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>




------------------------ Yahoo! Groups Sponsor ---------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/zMEolB/TM
---------------------------------------------------------------------~->

 
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/