Rank: Member
Groups: Registered, Registered Users, Unverified Users Joined: 10/31/2004(UTC) Posts: 14
Thanks: 4 times
|
johnl wrote: Did you look at the "Other Formulas" tab after following that link? Those formulas can be cut and pasted into Metastock.
Thanks for replay
Formula on site for Macd with EMA as Signal Line
Quote:
{Daily MACD} {This indicator uses the Equis Forum DLL} {Roy Larsen, 2004-2007}
{User settings} N:=Input("Daily MACD, Signal Periods",1,19,9); Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,1); {0, update at last bar of current frame} {1, update on each new bar} {2, update on first bar of new frame}
{Daily frame timing} {* Day counter from metastock@wabbit.com.au} M:=Month();A:=Int((14-M)/12);D:=DayOfMonth(); Y:=Year()+4800-A;B:=M+(12*A)-3; M:=D+Int((2+153*B)/5)+(365*Y)+Int(Y/4)-Int(Y/100)+Int(Y/400)-32045; {*} I:=M-ValueWhen(2,1,M); B:=I=1 AND Max(Hour(),Minute())=0; G:=LastValue(Highest(Sum(I>0,5))=5); I:=I AND B=0 OR ValueWhen(2,1,B); M:=G+I; F:=G+(M=0)*ExtFml("Forum.Sum",Ref(I,1),1); A:=LastValue(Cum(1)-1)=Cum(1); B:=Alert(A,2)*(A=0); J:=If(F,1,If(Alert(F,2)=0 AND M,2,0)); J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J); J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
{Daily CLOSE} K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
{Calculate and plot Daily MACD} X:=0.15; Y:=0.075; N:=2/(N+1); X:=If(Cum(J>0)=1,K,PREV*If(J,1-X,1)+If(J,K*X,0)); {X:=If(Cum(J>0)=1,K,ValueWhen(1,J,PREV)*(1-X)+K*X);} Y:=If(Cum(J>0)=1,K,PREV*If(J,1-Y,1)+If(J,K*Y,0)); {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, PREV*If(J,1-N,1)+If(J,R*N,0)); {Z:=If(Cum(J>0)=1,R,ValueWhen(1,J,PREV)*(1-N)+R*N);} R; {MACD} Z; {Signal}
I am trying to convert EMA Signal Line to SMA Signal Line as follow
Quote:
{Daily MACD} {This indicator uses the Equis Forum DLL} {Roy Larsen, 2004-2007}
{User settings} N:=Input("Daily MACD, Signal Periods",1,19,9); Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,1); {0, update at last bar of current frame} {1, update on each new bar} {2, update on first bar of new frame}
{Daily frame timing} {* Day counter from metastock@wabbit.com.au} M:=Month();A:=Int((14-M)/12);D:=DayOfMonth(); Y:=Year()+4800-A;B:=M+(12*A)-3; M:=D+Int((2+153*B)/5)+(365*Y)+Int(Y/4)-Int(Y/100)+Int(Y/400)-32045; {*} I:=M-ValueWhen(2,1,M); B:=I=1 AND Max(Hour(),Minute())=0; G:=LastValue(Highest(Sum(I>0,5))=5); I:=I AND B=0 OR ValueWhen(2,1,B); M:=G+I; F:=G+(M=0)*ExtFml("Forum.Sum",Ref(I,1),1); A:=LastValue(Cum(1)-1)=Cum(1); B:=Alert(A,2)*(A=0); J:=If(F,1,If(Alert(F,2)=0 AND M,2,0)); J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J); J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
{Daily CLOSE} K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
{Calculate and plot Daily MACD} X:=0.15; Y:=0.075; N:=2/(N+1); X:=If(Cum(J>0)=1,K,PREV*If(J,1-X,1)+If(J,K*X,0)); {X:=If(Cum(J>0)=1,K,ValueWhen(1,J,PREV)*(1-X)+K*X);} Y:=If(Cum(J>0)=1,K,PREV*If(J,1-Y,1)+If(J,K*Y,0)); {Y:=If(Cum(J>0)=1,K,ValueWhen(1,J,PREV)*(1-Y)+K*Y);} R:=X-Y; Z:=Cum((J>0)* R); R; {MACD} (Z-ValueWhen(N+1,J>0,Z))/N;{Signal}
But I am getting horizontal line value zero for Signal Line . I am not getting what I am doing wrong .
Thanks
Harish
|