logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
mstt  
#1 Posted : Thursday, May 31, 2007 7:24:15 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

The Weekly CCI formula for EOD charts I posted a couple of weeks ago contained a weekly counter algorithm for which another member of this forum claims ownership. While it is my belief that an algorithm cannot be subject to copyright, I have removed the code in good faith. The removed module has been replaced by one using a United States Naval Observatory daily counter algorithm recently demonstrated by Wabbit.

I’ve applied the same algorithm to a Daily CCI for intraday charts but have not yet been able to check it for accuracy. Both formulas should provide some learning opportunities for those with a mind to do some “tyre kicking”. Notice that these formulas require the Equis Forum DLL, so make sure that it’s installed before attempting to load either one. You can find the DLL in the Files section.


Roy
MetaStock Tips & Tools

Code:

{Weekly CCI for EOD charts}
{This indicator uses the Equis Forum DLL}
{Roy Larsen, 2007}
{User settings}
N:=Input("Weekly CCI, Periods",3,25,13);
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}
 
{Weekly 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:=Int(M/7);
I:=I-ValueWhen(2,1,I);A:=DayOfWeek();
G:=LastValue(Highest(Sum(A>4,8))=8);
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 prices}
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)));
Hw:=ValueWhen(1,Hw>0,Hw);
Lw:=ValueWhen(1,Lw>0,Lw); Tw:=(Hw+Lw+K)/3;
 
{Calculate Weekly CCI and plot result}
M:=Cum((J>0)*Tw); Ma:=(M-ValueWhen(N+1,J,M))/N;
Md:=(Abs(Ma-Tw)+Abs(Ma-ValueWhen(2,J,Tw))+
Abs(Ma-ValueWhen(3,J,Tw))+(N>3)*Abs(Ma-ValueWhen(4,J,Tw))+
(N>4)*Abs(Ma-ValueWhen(5,J,Tw))+(N>5)*Abs(Ma-ValueWhen(6,J,Tw))+
(N>6)*Abs(Ma-ValueWhen(7,J,Tw))+(N>7)*Abs(Ma-ValueWhen(8,J,Tw))+
(N>8)*Abs(Ma-ValueWhen(9,J,Tw))+(N>9)*Abs(Ma-ValueWhen(10,J,Tw))+
(N>10)*Abs(Ma-ValueWhen(11,J,Tw))+(N>11)*Abs(Ma-ValueWhen(12,J,Tw))+
(N>12)*Abs(Ma-ValueWhen(13,J,Tw))+(N>13)*Abs(Ma-ValueWhen(14,J,Tw))+
(N>14)*Abs(Ma-ValueWhen(15,J,Tw))+(N>15)*Abs(Ma-ValueWhen(16,J,Tw))+
(N>16)*Abs(Ma-ValueWhen(17,J,Tw))+(N>17)*Abs(Ma-ValueWhen(18,J,Tw))+
(N>18)*Abs(Ma-ValueWhen(19,J,Tw))+(N>19)*Abs(Ma-ValueWhen(20,J,Tw))+
(N>20)*Abs(Ma-ValueWhen(21,J,Tw))+(N>21)*Abs(Ma-ValueWhen(22,J,Tw))+
(N>22)*Abs(Ma-ValueWhen(23,J,Tw))+(N>23)*Abs(Ma-ValueWhen(24,J,Tw))+
(N>24)*Abs(Ma-ValueWhen(25,J,Tw)))/N; (Tw-Ma)/(Md*0.015);


Code:
 
{Daily CCI for intraday charts}
{This indicator uses the Equis Forum DLL}
{Roy Larsen, 2007}

{User settings}
N:=Input("Daily CCI, Periods",3,25,5);
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 prices}
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)));
Hw:=ValueWhen(1,Hw>0,Hw);
Lw:=ValueWhen(1,Lw>0,Lw); Tw:=(Hw+Lw+K)/3;

{Calculate Daily CCI and plot result}
M:=Cum((J>0)*Tw); Ma:=(M-ValueWhen(N+1,J,M))/N;
A:=LastValue((N>5)*5);B:=LastValue((N>10)*10);
D:=LastValue((N>15)*15);F:=LastValue((N>20)*20);
Md:=(Abs(Ma-Tw)+Abs(Ma-ValueWhen(2,J,Tw))+
Abs(Ma-ValueWhen(3,J,Tw))+(N>3)*Abs(Ma-ValueWhen(4,J,Tw))+
(N>4)*Abs(Ma-ValueWhen(5,J,Tw))+(N>5)*Abs(Ma-ValueWhen(A+1,J,Tw))+
(N>6)*Abs(Ma-ValueWhen(A+2,J,Tw))+(N>7)*Abs(Ma-ValueWhen(A+3,J,Tw))+
(N>8)*Abs(Ma-ValueWhen(A+4,J,Tw))+(N>9)*Abs(Ma-ValueWhen(A+5,J,Tw))+
(N>10)*Abs(Ma-ValueWhen(B+1,J,Tw))+(N>11)*Abs(Ma-ValueWhen(B+2,J,Tw))+
(N>12)*Abs(Ma-ValueWhen(B+3,J,Tw))+(N>13)*Abs(Ma-ValueWhen(B+4,J,Tw))+
(N>14)*Abs(Ma-ValueWhen(B+5,J,Tw))+(N>15)*Abs(Ma-ValueWhen(D+1,J,Tw))+
(N>16)*Abs(Ma-ValueWhen(D+2,J,Tw))+(N>17)*Abs(Ma-ValueWhen(D+3,J,Tw))+
(N>18)*Abs(Ma-ValueWhen(D+4,J,Tw))+(N>19)*Abs(Ma-ValueWhen(D+5,J,Tw))+
(N>20)*Abs(Ma-ValueWhen(F+1,J,Tw))+(N>21)*Abs(Ma-ValueWhen(F+2,J,Tw))+
(N>22)*Abs(Ma-ValueWhen(F+3,J,Tw))+(N>23)*Abs(Ma-ValueWhen(F+4,J,Tw))+
(N>24)*Abs(Ma-ValueWhen(F+5,J,Tw)))/N;(Tw-Ma)/(Md*0.015);


Jose  
#2 Posted : Thursday, May 31, 2007 11:56:30 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Your compliance to Copyright laws is much appreciated. Thank you. Jose Silva
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.