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

Re: [EquisMetaStock Group] Simple Moving Average using first bar of each week



PureBytes Links

Trading Reference Links

Sam

For weekly values on daily charts I think you should stay away from the PREV based code. The
difference in accuracy is minimal but the processing overheads are significant. I'm still hoping to
come up with a method that doesn't need to Cum() all weekly data but for now I still believe that's
the best way to go.

Roy

----- Original Message ----- 
From: "sabboushi2000" <Yahoo@xxxxxxxxxxxxxxx>
To: <equismetastock@xxxxxxxxxxxxxxx>
Sent: Monday, February 09, 2004 5:37 AM
Subject: Re: [EquisMetaStock Group] Simple Moving Average using first bar of each week


> Thanks Roy - I appreciate your assistance.
>
> I don't understand the basis behind how the LastValue ( J + PREV -
> PREV ) converts J into a constant (or exactly what that means to
> MS).
> Although this certainly works as you've outlined, I cannot get it to
> work for my specific case:
>
> EMAPERIODS:= Fml(".EMAPERIODS");   {where EMAPERIODS is a constant
> (8)}
>
> J:= LastValue( EMAPERIODS + PREV - PREV );
>
> Mov( C , J , E )
>
> Error message:   This variable or expression must contain only
> constant data.
>
> Any ideas why your trick won't work for my case?
>
> With Regards-
> Sam
>
>
> --- In equismetastock@xxxxxxxxxxxxxxx, "Roy Larsen" <rlarsen@xxxx>
> wrote:
> > Here are three versions of a weekly Monday CLOSE SMA. The first
> formula is less accurate than the
> > other two because of the errors introduced by cumulating the data
> for every Monday on the chart then
> > subtracting the unwanted Monday data. The advantage of this code is
> that it does not require PREV.
> >
> > The second and third formulas are more accurate because there is no
> fractional component in the 'J'
> > variable cumulations. This variable calculates the look-back
> periods (in bars, not weeks) for Sum()
> > or Mov(). In both formulas the 'J' variable is converted to operate
> legitimately as a constant in
> > either the Sum() or Mov() functions.
> >
> > The last line of the third formula can be broken down as follows.
> >
> > Mov(   {moving average of}
> >  K*M,  {data array includes only the CLOSE when Monday is true}
> >   LastValue(J+PREV-PREV),   {'J' periods in the form of a constant
> as required by Mov()}
> >    S)  {simple moving average}
> >     *J/D;  {multiply MA by look-back periods and divide result by
> weeks}
> >
> > It is clear from the makeup of this last line that moving between
> different periodises on the one
> > chart is rarely a matter of making simple changes. As you've
> already discovered the data array needs
> > to created, the sampling of that data needs to be managed, and the
> number of look-back periods also
> > need to adjusted to allow for holidays. The basic functions just
> can't cut it.
> >
> > Roy
> >
> >   {Monday Close SMA 1}
> >   {for use on daily charts}
> > D:=Input("Periods in Weeks",1,100,10);
> > M:=DayOfWeek()<=ValueWhen(2,1,DayOfWeek());
> > K:=ValueWhen(1,M,C);
> > G:=Cum(M*K);
> > X:=(G-ValueWhen(D+1,M,G))/D;
> > X;
> >
> >   {Monday Close SMA 2}
> >   {for use on daily charts}
> > D:=Input("Periods in Weeks",1,100,10);
> > M:=DayOfWeek()<=ValueWhen(2,1,DayOfWeek());
> > J:=Cum(1)-ValueWhen(D+1,M,Cum(1));
> > K:=ValueWhen(1,M,C);
> > Sum(K*M,LastValue(J+PREV-PREV))/D;
> >
> >   {Monday Close SMA 3}
> >   {for use on daily charts}
> > D:=Input("Periods in Weeks",1,100,10);
> > M:=DayOfWeek()<=ValueWhen(2,1,DayOfWeek());
> > J:=Cum(1)-ValueWhen(D+1,M,Cum(1));
> > K:=ValueWhen(1,M,C);
> > Mov(K*M,LastValue(J+PREV-PREV),S)*J/D;
> >
> >
> > ----- Original Message ----- 
> > From: "sabboushi2000" <Yahoo@xxxx>
> > To: <equismetastock@xxxxxxxxxxxxxxx>
> > Sent: Friday, February 06, 2004 2:53 AM
> > Subject: [EquisMetaStock Group] Simple Moving Average using first
> bar of each week
> >
> >
> > > Hi-
> > >
> > > Am trying to use EOD daily data to create a Moving Average for the
> > > previous 3 weeks - by using the Close of the first bar of each
> > > week AND by using the MOV function.
> > >
> > > Example:  Today is Wednesday.  I want a simple 3 day moving
> average
> > > using the following data:
> > >
> > >
> > >
> > >     2/17 Wednesday
> > >     2/16
> > >     2/15 Monday  Close: 10
> > >
> > >     2/12 Friday
> > >     2/11
> > >     2/10
> > >     2/9  Tuesday Close: 15
> > >     2/8  Monday Holiday
> > >
> > >     2/5  Friday
> > >     2/4
> > >     2/3
> > >     2/2
> > >     2/1  Monday  Close: 20
> > >
> > > The result I am looking for in this example would be (10 + 15 +
> > > 20) / 3 = 15
> > >
> > > (2/9 Tuesday was first trading day of that week since Monday was a
> > > trading Holiday)
> > >
> > >
> > > NOTE: I know I can create a formula to create this moving average
> > > without using the MOV function, but I don't really want to create
> a
> > > simple moving average using 3 data points - I just used this as a
> > > simple example for discussion purposes.
> > >
> > > I've tried using valuewhen to identify the first close value I
> want
> > > MS8.01 EOD to use, wishing that the formula would "increment" to
> each
> > > previous bar that met the condition - but no such luck.  The
> formula
> > > I tried:
> > >      Mov(ValueWhen(1,FIRSTDAYOFWEEK, C) ,3 ,S )
> > > where FIRSTDAYOFWEEK is a custom indicator that is true on the
> first
> > > trading day of each week.  My problem would be solved if MS
> > > incremented the "1" in my formula to 2 and 3 to get the data
> points I
> > > want it to use - but of course I'm being naive...
> > >
> > > Any geniuses out there that can think outside my box?
> > >
> > > With Regards-
> > > Sam
> > >
> > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/equismetastock/

<*> To unsubscribe from this group, send an email to:
     equismetastock-unsubscribe@xxxxxxxxxxxxxxx

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