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

Re: [Metastockusers] MACD WEEKLY



PureBytes Links

Trading Reference Links

Michael



>  Need help for MACD weekly (not histogram) indicator construction

Try this. I posted this on the equismetastock group a couple of days ago.
This is the same code but with the pseudo histogram display commented out.

Roy

  {Weekly MACD - Close (Commented)}
  {© 2003 Roy Larsen}
  {rlarsen@xxxxxxxxxxxxxx}
  {use on daily charts}
D:=Input("Signal Periods (in Weeks)",1,19,9);
Q:=Input("1=Update at Friday bar, Dynamic Current Week",0,0,0);
Q:=Input("2=Update at Friday bar, 3=Update at Monday bar",1,3,2);
 {1=dynamic current week, MS compatible}
 {2=update @ end of week except when no Friday}
 {3=update @ start of new week}
A:=DayOfWeek()=5;
  {normal Friday end of week}
B:=DayOfWeek()<=Ref(DayOfWeek(),-1);
  {missed Friday end of week}
F:=LastValue(Cum(1))=Cum(1);
  {last bar of chart - pseudo Friday?}
X:=0.15; Y:=0.075; D:=2/(D+1);
  {3 EMA ratios}
J:=If(A,1,If(Alert(A,2)=0 AND B,2,0));
  {end of week, 1 for Friday or 2 for Monday}
J:=If(F AND J=0 AND Q=1,1,J);
  {last bar as Friday for dynamic current week}
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2,1,C)));
  {if end-of-week signal use CLOSE for Friday or
   previous CLOSE for Monday}
M:=If(Cum(J>0)=1,K,ValueWhen(1,J,PREV)*(1-X)+K*X);
  {nominal 12 week EMA}
M:=If(A AND Q=3,ValueWhen(2,1,M),M);
  {delay Friday signals if option selected}
N:=If(Cum(J>0)=1,K,ValueWhen(1,J,PREV)*(1-Y)+K*Y);
  {nominal 26 week EMA}
N:=If(A AND Q=3,ValueWhen(2,1,N),N);
  {delay Friday signals if option selected}
R:=M-N;
  {difference between two EMA's - MACD}
Z:=If(Cum(J>0)=1,R,ValueWhen(1,J,PREV)*(1-D)+R*D);
  {MACD signal line}
R; {MACD}
{If(J>0 AND R>Z,R,0);} {pseudo MACD histogram}
{If(J>0 AND R<=Z,R,0);} {pseudo MACD histogram}
Z; {signal}



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/Lj3uPC/Me7FAA/ySSFAA/zMEolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
Metastockusers-unsubscribe@xxxxxxxxxxx

 

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