y


 
Missing trading days
Momentum - normalized
Momentum, LRS-smoothed

 

Missing trading days

{ Plots missing daily (weekday) bars count }{ ©Copyright 2003-2004 Jose Silva }{ josesilva22@yahoo.com }

ChkVol:=Input("Zero-volume days = missing data days?  Yes=1, No=0",0,1,1);
VolMissing:=If(ChkVol,V=0,0);

limit:=1960;  {do not change limit year}
LimLeap:=Frac(limit/4)=0 AND Frac(limit/100)<>0
 OR Frac(limit/400)=0;
NoCount:=limit*365+Int(limit/4)
 -Int(limit/100)+Int(limit/400)-LimLeap;
leap:=Frac(Year()/4)=0 AND Frac(Year()/100)<>0
 OR Frac(Year()/400)=0;
y:=Year()*365+Int(Year()/4)
 -Int(Year()/100)+Int(Year()/400)-NoCount;
m:=
 If(Month()=2,31-leap,
 If(Month()=3,59,
 If(Month()=4,90,
 If(Month()=5,120,
 If(Month()=6,151,
 If(Month()=7,181,
 If(Month()=8,212,
 If(Month()=9,243,
 If(Month()=10,273,
 If(Month()=11,304,
 If(Month()=12,334,
 -leap)))))))))));
DayNr:=y+m+DayOfMonth();
WkDayCount:=
 Int((DayNr+3)/7)+   {Mon}
 Int((DayNr+2)/7)+   {Tue}
 Int((DayNr+1)/7)+   {Wed}
 Int((DayNr)/7)+     {Thu}
 Int((DayNr-1)/7);   {Fri}

WkDayCount-ValueWhen(2,1,WkDayCount)-1
 +VolMissing

(Go Top...)

Momentum - normalized

{ Normalized Momentum v3.1 }{ ©Copyright 2003-2004 Jose Silva }{ josesilva22@yahoo.com }

pds:=Input("Momentum periods",1,2520,10);
pdsN:=Input("normalizing periods (1=none)",
 1,2520,63);
x:=Input("use Open=1 High=2 Low=3 Close=4 Volume=5 P=6",1,6,4);
plot:=Input("Momentum=1,  midpoint crossover Signals=2",1,2,1);

x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C)))));
y:=Ref(x,-pds);
ratio:=Min(x,y)/Max(x,y);
Mom:=If(x>y,2-ratio,ratio)*100-100;
MomNorm:=(Mom-LLV(Mom,pdsN))
 /(HHV(Mom,pdsN)-LLV(Mom,pdsN)+.000001)*100;
MomNorm:=If(pdsN=1,Mom,MomNorm);
midpt:=If(pdsN=1,0,
 Cum(MomNorm)/Cum(IsDefined(MomNorm)));
signals:=
 Cross(MomNorm,midpt)-Cross(midpt,MomNorm);

midpt;If(plot=2,signals,MomNorm)

(Go Top...)

Momentum, LRS-smoothed

{ LRS-smoothed normalized Momentum v2 }{ ©Copyright 2003 Jose Silva }{ josesilva22@yahoo.com }

pds:=Input("Momentum periods",2,2520,10);
smooth:=Input("LRS smoothing periods",
 1,252,10);
plot:=Input("Momentum=1,  Smoothed=2,  Double smoothed=3",1,3,2);
x:=Input("use Open=1 High=2 Low=3 Close=4 Volume=5 P=6",1,6,4);

x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C)))));
y:=Ref(x,-pds);
ratio:=Min(x,y)/Max(x,y);
Mom:=If(x>y,2-ratio,ratio)*100-100;
MoSm:=LinRegSlope(Mom,smooth)*10;
MoSm:=If(smooth<2,Mom,MoSm);
MoSm2:=LinRegSlope(MoSm,smooth)*4;
MoSm2:=If(smooth<2,Mom,MoSm2);

If(plot=1,Cum(Mom)/(Cum(Mom>-100)+.000001),
 If(plot=2,Cum(MoSm)/(Cum(MoSm>-100)+.000001),
 Cum(MoSm2)/(Cum(MoSm2>-100)+.000001)));

If(plot=1,Mom,If(plot=2,MoSm,MoSm2))

(Go Top...)