Jeff: Here's my first attempt to translate BNS into QP. It's really the reason I was focusing on slope and CCI. This scan looks for positive slopes for CCI(13), MACD (5,35,4) and Stochastics (8,3). It all looks for strong "persistence,," the percentage of days over 6 monts that Chaikin's Money Flow is greater than 0. All my scans recently have reflected my pursuit of a formula for BNS. This formula leaves a lot out, but it's a start at least. The period for slope is 3, because BNS is looking for quick moves up, I think.
//BNS, translated to QP by Brooke //loosely based on system developed by Bill Sandusky //based on John Sugas' formula for cci //and Bob Jagow's formula for slope
output="ccicross.lst"; input="epscomb.lst"; issuetype=common; exchange nyse,nasdaq,amex; daystoload = 250;
Integer ia, Sa, Sx, Sxx; float cci, cciprev, cciprev2, cciprev3, Symacd, Sxymacd, Systoch, Sxystoch, ccislope, ccislopeprev, macdslope, stochslope, 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;
Set MACD = 5,35,4; Set Stochastic = 8, 3, 3;
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; Symacd:=macd(0)+macd(-1)+macd(-2); Systoch:=StochasticPctK(0)+StochasticPctK(-1)+StochasticPctK(-2); Sxx := Sxx + ia*ia; Sxy := (0*cci)+(-1*cciprev)+(-2*cciprev2); Sxyb := (0*cciprev)+(-1*cciprev2)+(-2*cciprev3); Sxymacd:=(0*macd(0))+(-1*macd(-1))+(-2*macd(-2)); Sxystoch:=(0*StochasticPctK(0))+(-1*StochasticPctK(-1))+(0*StochasticPctK(-2));
next ia; ccislope := (Sa*Sxy - Sx*Sy)/(Sa*Sxx - Sx*Sx); ccislopeprev := (Sa*Sxyb - Sx*Syb)/(Sa*Sxx - Sx*Sx); macdslope:= (Sa*Sxymacd - Sx*Symacd)/(Sa*Sxx - Sx*Sx); stochslope:= (Sa*Sxystoch - Sx*Systoch)/(Sa*Sxx - Sx*Sx);
if ccislope>0 and macdslope>0 and stochslope>0 and persistence(0)>80 then //Persistence is percentage of days over 6 monts that Chaikin's Money Flow is > 0. println symbol:-6," BUY: Close: ", close(0):-7:3, ",", " Up: ", close(0)-close(-1):4:3, ","," Volume: ", vol(0):4, ","," CCI: ", cci:-3:4,",", " QRS: ", QRS(0):2, ","," Sharesfloat: ", Sharesfloat:6:3, ", ",Description:-12; endif; |