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

Re: [EquisMetaStock Group] Weekly Stochastics



PureBytes Links

Trading Reference Links

DP

> Here is my problem:
> I want to calculate Weekly Stochastics. The stoch function looks like Stoch(5,3), which I
understand is reffered as daily stoch, but how could I calculate weekly stoch values?

Stoch(5,3) relates to the periodicy of the chart you are using it on. It will work just the same on
a weekly chart as an intraday chart. If your charts are daily and that's the only timeframe you want
to use then you need to be a little more creative to display weekly Stoch values on daily charts.
One of these indicators will provide the information you require. Note that before pasting these
into the indicator builder you will need Jose's "Calendar Week Counter" which can be found at
http://users.bigpond.com/prominex/MetaStock/WeekCount.txt
and it is also included below.

Roy

=====================
Calendar Week counter
=====================

---8<---------------------------

{Week counter v2.0, Gregorian calendar}
{Count is independent of any missing chart data}
{©Copyright 2003-2004 Jose Silva}
{josesilva22@xxxxxxxxx}

limit:=2000;  {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();
WkCount:=Int((DayNr-1)/7)+(Year()>=limit);

WkCount

---8<---------------------------

---8<---------------------------
  {Weekly Stochastic Osc EMA}
  {©2004 Roy Larsen, rlarsen@xxxxxxxxxxxxxx}
  {for use on daily charts with
   Jose Silva's "Calendar Week counter"}
F:=Input("End of Week,  5=Friday  6=Saturday  7=Sunday",5,7,5);
K:=Input("%K Periods in Weeks",1,99,5);
N:=Input("%K Slowing Periods" ,1,99,3);
R:=Input("%D EMA Periods",1,99,3);  R:=2/(1+R);
Q:=Input("Display Mode,  0=Static  1=Dynamic  2=Test",0,2,2);
  {0=Display, update on Friday when possible}
  {1=Display, update on each new bar}
  {2=Backtest, update on first bar of new week}
I:=Fml("Calendar Week counter");
I:=Abs(I-ValueWhen(2,1,I));
M:=I>0;
D:=DayOfWeek();
G:=LastValue(Highest(Sum(DayOfWeek()=F,5))=5);
F:=G OR (DayOfWeek()=F AND I=0);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=LastValue(Cum(1))=Cum(1);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+Q=2,1,(B=0)*J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
M:=G OR M;
Hw:=HighestSince(1,M,H);
Hw:=ValueWhen(1,J,If(J=1,Hw,ValueWhen(2,1,Hw)));
Lw:=LowestSince(1,M,L);
Lw:=ValueWhen(1,J,If(J=1,Lw,ValueWhen(2,1,Lw)));
Cw:=ValueWhen(1,J,If(J=1,C,ValueWhen(2,1,C)));
Hw:=ValueWhen(1,Hw>0,Hw);
Lw:=ValueWhen(1,Lw>0,Lw);
Cw:=ValueWhen(1,Cw>0,Cw);
Z:=Cum((Cw-LowestSince(K,J,Lw))*(J>0));
Z:=Z-ValueWhen(N+1,J,Z);
I:=Cum((HighestSince(K,J,Hw)- LowestSince(K,J,Lw))*(J>0));
I:=I-ValueWhen(N+1,J,I);
I:=ValueWhen(1,Cum(I>0)>0,I);
X:=100*Z/I;
X:=ValueWhen(1,Cum(J>0)>=K+N,X);
Y:=ValueWhen(1,J,PREV)*(1-R)+X*R;
X; {%K}
Y; {%D}
---8<---------------------------


---8<---------------------------
  {Weekly Stochastic Osc SMA}
  {©2004 Roy Larsen, rlarsen@xxxxxxxxxxxxxx}
  {for use on daily charts with
   Jose Silva's "Calendar Week counter"}
F:=Input("End of Week,  5=Friday  6=Saturday  7=Sunday",5,7,5);
K:=Input("%K Periods ( in Weeks )",1,99,5);
N:=Input("%K Slowing Periods" ,1,99,3);
R:=Input("%D SMA Periods",1,99,3);
Q:=Input("Display Mode,  0=Static  1=Dynamic  2=Test",0,2,2);
  {0=Display, update on Friday when possible}
  {1=Display, update on each new bar}
  {2=Backtest, update on first bar of new week}
I:=Fml("Calendar Week counter");
I:=Abs(I-ValueWhen(2,1,I));
M:=I>0;
D:=DayOfWeek();
G:=LastValue(Highest(Sum(DayOfWeek()=F,5))=5);
F:=G OR (DayOfWeek()=F AND I=0);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=LastValue(Cum(1))=Cum(1);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+Q=2,1,(B=0)*J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
M:=G OR M;
Hw:=HighestSince(1,M,H);
Hw:=ValueWhen(1,J,If(J=1,Hw,ValueWhen(2,1,Hw)));
Lw:=LowestSince(1,M,L);
Lw:=ValueWhen(1,J,If(J=1,Lw,ValueWhen(2,1,Lw)));
Cw:=ValueWhen(1,J,If(J=1,C,ValueWhen(2,1,C)));
Hw:=ValueWhen(1,Hw>0,Hw);
Lw:=ValueWhen(1,Lw>0,Lw);
Cw:=ValueWhen(1,Cw>0,Cw);
Z:=Cum((Cw-LowestSince(K,J,Lw))*(J>0));
Z:=Z-ValueWhen(N+1,J,Z);
I:=Cum((HighestSince(K,J,Hw)- LowestSince(K,J,Lw))*(J>0));
I:=I-ValueWhen(N+1,J,I);
I:=ValueWhen(1,Cum(I>0)>0,I);
X:=100*Z/I;
X:=ValueWhen(1,Cum(J>0)>=K+N,X);
Y:=Cum((J>0)*X);
Y:=(Y-ValueWhen(R+1,J,Y))/R;
X; {%K}
Y; {%D}
---8<---------------------------


---8<---------------------------
  {Weekly Double Smoothed Stochastic}
  {©2004 Roy Larsen, rlarsen@xxxxxxxxxxxxxx}
  {for use on daily charts with
   Jose Silva's "Calendar Week counter"}
N:=Input("Double Stochastic Periods",2,99,10);
R:=Input("Smoothing Periods",1,9,3);
R:=2/(R+1);
F:=Input("End of Week,  5=Friday  6=Saturday  7=Sunday",5,7,5);
Q:=Input("Display Mode,  0=Static  1=Dynamic  2=Test",0,2,2);
  {0=Display, update on Friday when possible}
  {1=Display, update on each new bar}
  {2=Backtest, update on first bar of new week}
I:=Fml("Calendar Week counter");
I:=Abs(I-ValueWhen(2,1,I));
M:=I>0;
G:=LastValue(Highest(Sum(DayOfWeek()=F,5))=5);
F:=G OR (DayOfWeek()=F AND I=0);
A:=LastValue(Cum(1)-1)=Cum(1);
B:=LastValue(Cum(1))=Cum(1);
J:=If(F,1,If(Alert(F,2)=0 AND M,2,0));
J:=If(A+LastValue(J)>2 OR B+Q=2,1,(B=0)*J);
J:=If(G,1,If(Q=2 OR Cum(J)<=1,M*2,J));
M:=G OR M;
Hw:=HighestSince(1,M,H);
Hw:=ValueWhen(1,J,If(J=1,Hw,ValueWhen(2-G,1,Hw)));
Lw:=LowestSince(1,M,L);
Lw:=ValueWhen(1,J,If(J=1,Lw,ValueWhen(2-G,1,Lw)));
K:=ValueWhen(1,J,If(J=1,C,ValueWhen(2-G,1,C)));
Ls:=LowestSince(N,J,Lw);
Hs:=HighestSince(N,J,Hw);
P0:=((K-Ls)/(Hs-Ls))*100;
P1:=ValueWhen(1,J,PREV)*(1-R)+P0*R;
Lp:=LowestSince(N,J,P1);
Hp:=HighestSince(N,J,P1);
P2:=((P1-Lp)/(Hp-Lp))*100;
ValueWhen(1,J,PREV)*(1-R)+P2*R;
---8<---------------------------




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/equismetastock/

<*> To unsubscribe from this group, send an email to:
     equismetastock-unsubscribe@xxxxxxxxxxxxxxx

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