You did it! O frabjous day! You have to put // in front of println dday," , ",cci (near the end), so it does't print out all that junk. I'll try to figure out why you don't need the /3 in there, though it may remain a mystery. It's as you say: the values do match those in WOW, and in your earlier formula.
Speaking of which.......
Here's a scan for the 3-day slope of CCI(13) for today and the previous day. Values match those in WOW, give or take a few tenths of a point. I chose a 3-day slope because I've got BNS in my sights, and BNS looks for quick changes in direction. I don't think you'd want a longer period for slope in this case.
Oh, back to the variable CCI scan for a second: Have you noticed how slowly it runs? I wonder why that is. So far QP has kept up with our madness, but this latest CCI scan really hobbles it.
Anyway, here's the slope of CCI:
//3-day slope for cci (13) for today and previous day //based on John Sugas' formula for cci //and Bob Jagow's formula for slope
output="ccicross.lst";
issuetype=common; exchange nyse,nasdaq,amex; daystoload = 250;
Integer ia, Sa, Sx, Sxx; float cci, cciprev, cciprev2, cciprev3, slope, slopeprev, Sxy, Sxyb, Sy, Syb, 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, Za, Zb, Zc, aa, bb, cc, dd, ee, ff, gg, hh, ii, jj, kk, ll, mm, nn, oo, pp;
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 ; Za :=(high(-25)+low(-25)+close(-25))/3 ; Zb :=(high(-26)+low(-26)+close(-26))/3 ; Zc :=(high(-27)+low(-27)+close(-27))/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 ; nn :=(O+P+Q+R+S+T+U+V+W+X+Y+Z+Za)/13 ; oo :=(P+Q+R+S+T+U+V+W+X+Y+Z+Za+Zb)/13 ; pp :=(Q+R+S+T+U+V+W+X+Y+Z+Za+Zb+Zc)/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)+.00001; cciprev := (C-bb)/(0.015*(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)+abs(O-nn))/13)+.00001; cciprev2 := (D-cc)/(0.015*(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)+abs(O-nn)+abs(P-oo))/13)+.00001; cciprev3 := (E-dd)/(0.015*(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)+abs(O-nn)+abs(P-oo)+abs(Q-pp))/13)+.00001;
Sa := 3; Sx := 0; Sxx := 0; //Sxy := 0; //Sy := 0; for ia = 1 - Sa to 0 do Sx := Sx + ia; Sy := cci + cciprev + cciprev2; Syb:= cciprev + cciprev2 + cciprev3; Sxx := Sxx + ia*ia; Sxy := (0*cci)+(-1*cciprev)+(-2*cciprev2); Sxyb := (0*cciprev)+(-1*cciprev2)+(-2*cciprev3); next ia; slope := (Sa*Sxy - Sx*Sy)/(Sa*Sxx - Sx*Sx); slopeprev := (Sa*Sxyb - Sx*Syb)/(Sa*Sxx - Sx*Sx);
Println Symbol, ": CCI:", cci:8:2, ", CCIPREV:", cciprev:8:2, ", SLOPE:",slope:8:3, ", SLOPEPREV:",slopeprev:8:3; |