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

Re: [EquisMetaStock Group] Plot Daily / Weekly Indicator signal line (Simple Moving Average) in LowerTimeFr



PureBytes Links

Trading Reference Links

Hi Harish
 
 
I don't have all Daily/Weekly/Multi-Frame formulas or intraday data with me right now but I think you'll find that the problem lies with the revised definition of "N" immediately after the {Calculate and plot Daily MACD} header. comment out or delete the "N:=2/(N+1)" definition. This definition converts N periods to a ratio for the signal EMA and is not needed for the SMA calculation. The original N number IS required, and commenting out the redefinition allows the N variable to remain unchanged. I've tried my suggestion on EOD data and it appears to do as you require. I can't check it on intraday data right now.
 
I'm including Weekly and Multi-Frame MACD formulas with an SMA signal line. These formulas require the use of the Forum DLL, and the variable-length Sum function from this DLL is used to generate a more accurate SMA.
 
 
Regards
 
Roy
 
 
 {Multi-Frame D MACD E}
 {This indicator uses Equis Forum DLL}
 {Roy Larsen, 2008}
 
 {User settings}
N:=Input("Multi-Frame D MACD, Signal Periods",1,19,9);
F:=Input("Timeframe, 0=W  1=M  2=Q  3=6M  4=Y",0,4,0);
F:=If(F=1,1,If(F=2,3,If(F=3,6,If(F=4,12,0))));
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}
 
 {Timing signals}
{Day counter courtesy metastock@xxxxxxxxxxxxx}
M:=Month();A:=Int((14-M)/12);D:=DayOfMonth();
Y:=Year();X:=Y+4800-A;B:=M+(12*A)-3;Z:=Cum(1);
M:=If(F=0,D+Int((2+153*B)/5)+(365*X)+Int(X/4)-
Int(X/100)+Int(X/400)-32045,{day counter}
(Y-ValueWhen(1,Z=1,Y))*12+M){month counter};
I:=If(F=0,Int(M/7),Int((M-1)/Max(1,F)));
I:=I<>ValueWhen(2,1,I);
G:=LastValue(Lowest(Sum(I>0,5))=5);
I:=ExtFml("Forum.Sum",I,1);M:=G OR I;
F:=G OR (M=0)*ExtFml("Forum.Sum",Ref(I,1),1);
A:=LastValue(Z-1)=Z;B:=LastValue(Z)=Z;
J:=If(F,1,(Alert(F,2)=0)*M*2*(Z>1));
J:=If(A+LastValue(J)>2 OR B+(Q=1)=2,1,J);
J:=If(G,1,If(Q=2,M*2,J));
 
 {Frame CLOSE}
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
 
 {Calculate/plot MACD and signal}
X:=0.15; Y:=0.075; J:=J>0;
X:=If(Cum(J)=1,K,PREV*If(J,1-X,1)+J*K*X);
Y:=If(Cum(J)=1,K,PREV*If(J,1-Y,1)+J*K*Y);
R:=X-Y; A:=Cum(J);
M:=ExtFml("Forum.Sum",J*R,Z-ValueWhen(N+1,J,Z));
Z:=ValueWhen(1,A>N,ValueWhen(1,J,M)/N);
R; {Weekly MACD}
Z; {SMA signal line}
 
 
 
 {Weekly MACD S}
 {This indicator uses the Equis Forum DLL}
 {Roy Larsen, 2004-2007}
 
 {User settings}
N:=Input("Weekly MACD Signal Periods",1,19,9);
Q:=Input("Mode, 0=Static 1=Dynamic 2=Delayed",0,2,0);
 {0, update on last bar of current frame}
 {1, update on each new bar}
 {2, update on first bar of new frame}
 
{Weekly frame timing}
 {* Day counter from metastock@xxxxxxxxxxxxx}
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:=Int(M/7);
I:=I-ValueWhen(2,1,I);
G:=LastValue(Lowest(Sum(I>0,5))=5);
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));
 
 {Weekly CLOSE}
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
 
{Calculate and plot weekly MACD and signal line}
X:=0.15; Y:=0.075; J:=J>0; A:=Cum(J);
X:=If(Cum(J)=1,K,PREV*If(J,1-X,1)+J*K*X);
Y:=If(Cum(J)=1,K,PREV*If(J,1-Y,1)+J*K*Y);
R:=X-Y; Z:=Cum(1);
M:=ExtFml("Forum.Sum",J*R,Z-ValueWhen(N+1,J,Z));
Z:=ValueWhen(1,A>N,ValueWhen(1,J,M)/N);
R; {Weekly MACD}
Z; {SMA signal line}
 
 
 
 
----- Original Message -----
From: hkchheda
Sent: Tuesday, January 20, 2009 10:05 PM
Subject: [EquisMetaStock Group] Plot Daily / Weekly Indicator signal line (Simple Moving Average) in LowerTimeFr

Hi All ;

I am using Daily /Weekly Macd formula from
http://www.metastocktips.co.nz/ site by respected Roy Larsen . In
above formula by Roy Larsen signal line is exponential moving
average. I want to replace exponential moving average by simple
moving average as signal line in this indicator in lower time frame .

Can someone help me ?

Formula on site for Macd with EMA as Signal Line :

{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@xxxxxxxcom.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 :

{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@xxxxxxxcom.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 .

Can someone help me to solve the problem in formula .

Thanks

Harish Chheda



__________ Information from ESET NOD32 Antivirus, version of virus signature database 3779 (20090119) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
__._,_.___

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___