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

[Metastockusers] Re: Weekly MACD - Close



PureBytes Links

Trading Reference Links


Hi Roy

Its good of you to take the time to go through this.  Thanks a lot. 

If it isnt too much trouble a commented weekly MACD code would be 
very useful to exactly understand how the weekly timing mechanism 
works.  

On a separate but related note: whats the difference between using 
the PREV function and using say a REF(XXX,-1) function, given that 
the PREV function can be slow?  

Best regards

cav



--- In Metastockusers@xxxxxxxxxxxxxxx, "Roy Larsen" <rlarsen@xxxx> 
wrote:
> Hi cav
> 
> For your interest here's a 5-bar rolling frame MACD. Frame 
boundaries are based on the last bar of 
> data.
> 
>   {Rolling 5-Bar-Frame MACD}
>   {2005 Roy Larsen, rlarsen@xxxx}
> N:=Input("MACD Signal Frames",1,19,9);
> BarCount:=LastValue(Cum(1))-Cum(1);
> J:=Frac(BarCount/5)=0; {end of frame}
> K:=ValueWhen(1,J,C); {frame CLOSE}
> X:=0.15; Y:=0.075; N:=2/(N+1);
> X:=If(Cum(J>0)=1,K,ValueWhen(1,J,PREV)*(1-X)+K*X);
> Y:=If(Cum(J>0)=1,K,ValueWhen(1,J,PREV)*(1-Y)+K*Y);
> R:=X-Y;
> Z:=If(Cum(J>0)=1,R,ValueWhen(1,J,PREV)*(1-N)+R*N);
> R; {MACD}
> Z; {Signal}
> 
> Change the BarCount variable to this to tie frame boundaries to 
the first bar of data in a chart or 
> exploration.
> 
> BarCount:=Cum(1);
> 
> 
> > Thanks for the input.  Understand what you mean about "most of 
the
> > code defining the weekly timeframe" .. lol, tried unpicking it, 
but
> > haven't done it right.
> 
> Defining frame boundries for weekly data means identifying the 
first and last bar of each week, and 
> compensating when the last bar is other than Friday. To replicate 
MetaStock's weekly data the last 
> week must also be dynamic - i.e. the end of the frame rolls from 
Monday to Friday. That in itself is 
> something of a problem. Consider the Easter holiday weekend when 
both Friday and Monday are 
> non-trading days. Calculating an EMA, for example, is a little 
tricky when both Thursday and the 
> following Tuesady must each be regarded as the end of their 
respective weeks, assuming Tuesday is 
> the last bar of data. Just using Tuesday to signal a new week, and 
looking back to the previous bar 
> for the end of the previous week isn't sufficient to retrieve the 
two data samples required.
> 
> Would a commented Weekly MACD code help your understanding of how 
the weekly timing mechanism works?
> 
> > I take your point about tying the frame to the first bar - no
> > point.  Sorry if this sounds dumb, but by tying the frame to the
> > last bar - yes, every new bit of data will change the picture 
every
> > day, but isn't this what happens in a moving average anyway?
> 
> No it isn't what happens with a moving average. Existing values in 
a moving average stay fixed as 
> new data is added, regardless of the periodicity, because the 
contents of each frame (bar or week) 
> stays fixed. A rolling frame keeps moving the start and end points 
of each frame. It's quite 
> different.
> 
> > I guess where my thinking is leading me is that a Mon-Fri MACD 
is a
> > bit artificial?  Fridays trend change is relevant to the 
following
> > Monday?  So why set up the frame as Mon-Fri, rather than the 
last 5
> > trading days? Any views would be most welcome ..
> 
> Maybe, but I think not. I guess most of the worlds population base 
their activity on a very rigid 
> 7-day cycle. Everyone has a start of the week, and everyone has a 
finish of the week. This is so 
> deeply ingrained into our psyche that it has a huge influence on 
how traders and everyone else acts.
> 
> 
> Kind regards
> 
> Roy
> www.metstocktips.co.nz





------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/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/