Richard: I'm not getting errors when I run that scan. Maybe a line break was introduced in transit. But I have questions about that scan, which I've sent to Bill R. I wonder whether it's calculating CCI correctly, because of one variable -- I won't go into the details yet. For all I know, it could be correct.
In the meantime, here's a scan for CCI (13) that I have verified. It gives exactly the same values for CCI (13) that Window on Wall Street gives. It's essentially John Sugas' scan, but I've changed the periods to 13 and made one important change in the way absolute value was used.
John's CCI(8) scan had (0.015*abs((B-R)+(C-S)+(D-T)+(E-U)+(F-V)+abs(G-W)+(H-X)+(I-Y))/8), but that throws the values off, so that you get some odd numbers that don't agree with those in WOW.
Abs should be set up like this: cci := (B-R)/(0.015*(abs(B-R)+abs(C-S)+abs(D-T)+abs(E-U)+abs(F-V) +abs(G-W)+abs(H-X)+abs(I-Y))/8)
The formula for cci does call for calculating the absolute value of each of those results, not the absolute value of the whole thing.
Read Step 4 under the formula for CCI in "TA from A to Z." Here's a link to the page: equis.com
I noticed this only after comparing values with John's formula and WOW, and being mystified by some discrepancies.
Once you change the formula in QP, you get values exactly the same as those in WOW.
Here, then, are some scans:
CCI(8), by John Sugas (with abs corrected)
//cci(8), calculate value, by John Sugas
output="ccieight.lst";
float cci, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, R, S, T, U, V, W, X, Y;
B :=(high(0)+low(0)+close(0))/3 ; C :=(high(-1)+low(-1)+close(-1))/3 ; D :=(high(-2)+low(-2)+close(-2))/3 ; E :=(high(-3)+low(-3)+close(-3))/3 ; F :=(high(-4)+low(-4)+close(-4))/3 ; G :=(high(-5)+low(-5)+close(-5))/3 ; H :=(high(-6)+low(-6)+close(-6))/3 ; I :=(high(-7)+low(-7)+close(-7))/3 ; J :=(high(-8)+low(-8)+close(-8))/3 ; K :=(high(-9)+low(-9)+close(-9))/3 ; L :=(high(-10)+low(-10)+close(-10))/3 ; M :=(high(-11)+low(-11)+close(-11))/3 ; N :=(high(-12)+low(-12)+close(-12))/3 ; O :=(high(-13)+low(-13)+close(-13))/3 ; P :=(high(-14)+low(-14)+close(-14))/3 ; R :=(B+C+D+E+F+G+H+I)/8 ; S :=(C+D+E+F+G+H+I+J)/8 ; T :=(D+E+F+G+H+I+J+K)/8 ; U :=(E+F+G+H+I+J+K+L)/8 ; V :=(F+G+H+I+J+K+L+M)/8 ; W :=(G+H+I+J+K+L+M+N)/8 ; X :=(H+I+J+K+L+M+N+O)/8 ; Y :=(I+J+K+L+M+N+O+P)/8 ;
cci := (B-R)/(0.015*(abs(B-R)+abs(C-S)+abs(D-T)+abs(E-U)+abs(F-V)+abs(G-W)+abs(H-X)+abs(I-Y))/8); println symbol,": ",cci;
*******************
CCI(13), based on John's CCI(8) scan:
output="ccithirt.lst";
daystoload = 250;
float cci, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, ll, mm;
B :=(high(0)+low(0)+close(0))/3 ; C :=(high(-1)+low(-1)+close(-1))/3 ; D :=(high(-2)+low(-2)+close(-2))/3 ; E :=(high(-3)+low(-3)+close(-3))/3 ; F :=(high(-4)+low(-4)+close(-4))/3 ; G :=(high(-5)+low(-5)+close(-5))/3 ; H :=(high(-6)+low(-6)+close(-6))/3 ; I :=(high(-7)+low(-7)+close(-7))/3 ; J :=(high(-8)+low(-8)+close(-8))/3 ; K :=(high(-9)+low(-9)+close(-9))/3 ; L :=(high(-10)+low(-10)+close(-10))/3 ; M :=(high(-11)+low(-11)+close(-11))/3 ; N :=(high(-12)+low(-12)+close(-12))/3 ; O :=(high(-13)+low(-13)+close(-13))/3 ; P :=(high(-14)+low(-14)+close(-14))/3 ; Q :=(high(-15)+low(-15)+close(-15))/3 ; R :=(high(-16)+low(-16)+close(-16))/3 ; S :=(high(-17)+low(-17)+close(-17))/3 ; T :=(high(-18)+low(-18)+close(-18))/3 ; U :=(high(-19)+low(-19)+close(-19))/3 ; V :=(high(-20)+low(-20)+close(-20))/3 ; W :=(high(-21)+low(-21)+close(-21))/3 ; X :=(high(-22)+low(-22)+close(-22))/3 ; Y :=(high(-23)+low(-23)+close(-23))/3 ; Z :=(high(-24)+low(-24)+close(-24))/3 ;
aa :=(B+C+D+E+F+G+H+I+J+K+L+M+N)/13 ; bb :=(C+D+E+F+G+H+I+J+K+L+M+N+O)/13 ; cc :=(D+E+F+G+H+I+J+K+L+M+N+O+P)/13 ; dd :=(E+F+G+H+I+J+K+L+M+N+O+P+Q)/13 ; ee :=(F+G+H+I+J+K+L+M+N+O+P+Q+R)/13 ; ff :=(G+H+I+J+K+L+M+N+O+P+Q+R+S)/13 ; gg :=(H+I+J+K+L+M+N+O+P+Q+R+S+T)/13 ; hh :=(I+J+K+L+M+N+O+P+Q+R+S+T+U)/13 ; ii :=(J+K+L+M+N+O+P+Q+R+S+T+U+V)/13 ; jj :=(K+L+M+N+O+P+Q+R+S+T+U+V+W)/13 ; kk :=(L+M+N+O+P+Q+R+S+T+U+V+W+X)/13 ; ll :=(M+N+O+P+Q+R+S+T+U+V+W+X+Y)/13 ; mm :=(N+O+P+Q+R+S+T+U+V+W+X+Y+Z)/13 ;
cci := (B-aa)/(0.015*(abs(B-aa)+abs(C-bb)+abs(D-cc)+abs(E-dd)+abs(F-ee)+abs(G-ff)+abs(H-gg)+abs(I-hh)+abs(J-ii)+abs(K-jj)+abs(L-kk)+abs(M-ll)+abs(N-mm))/13);
//if //(B-R)/(0.015*(abs(B-R)+abs(C-S)+abs(D-T)+abs(E-U)+abs(F-V)+abs(G-W)+abs(H-X)+abs(I-Y)+abs(J-Ya)+abs(K-Yb)+abs(L-Yc)+abs(M-Yd)+abs(N-Ye))/13)<-100 then //println symbol,", ",description,", ",close(0); endif;
Println Symbol, ": ", cci:8:2;
********************
I'm going to add previous days' cci to these scans so we can look for cci crossing up through -100, for example.
I'm also hoping to reduce some of these with for loops, and making the scan so you can put in any period. Maybe John Sugas already has some ideas.
I'd like to get a good variable formula for cci so that we could move toward a formula for BNS (Bill's New System) in QP. Why -- when we've got it in WOW and Metastock? Because it's there. Maybe it'll lead to some insights into QP, too, or new trading formulas. Maybe authorities will lock me up. We shall see.
Brooke |