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

[EquisMetaStock Group] Revised Weekly CCI Inicator for EOD Charts



PureBytes Links

Trading Reference Links


The Weekly CCI formula for EOD charts I posted on the Equis Forum recently contained a weekly counter algorithm for which another member of that forum claimed 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 on the Equis Forum.



I've applied the same algorithm to a Daily CCI for intraday charts but have not yet been able to check it fully 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 formula.



Roy

www.metastocktips.co.nz

 



 

==============================

 

 {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@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);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);

 

==============================

 

==============================

 

 {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@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:=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);

 

==============================


[Non-text portions of this message have been removed]



 
Yahoo! Groups Links

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

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> 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/