I posted an incomplete version of Bill Riedeman's CCI scan at my Quotes Plus Scans site (http://members.aol.com/brookelise/qp.htm), because of an error I made while cutting and pasting. Sorry, everyone. Here are fixed versions of the scan. One version gives the value of CCI, and the other scans for stocks with CCI crossing up through -150.
//CCI, calculate value, by Bill Riedeman
output = "cciget.lst"; exchange nasdaq, nyse, amex;
integer i,N; float CCIT, CCIY, DAT, DAY, AT, AY;
N:=13;
//Number of periods in CCI calculation //Calculate simple MA of typical price for N periods //for Today and Yesterday. AT/AY are running averages.
AT:= 0; for i=1 to N-1 step 1 do AT := AT+close(-i)+high(-i)+low(-i); next i;
AY:=(close(-N)+high(-N)+low(-N)+AT)/(3*N); //Make sure to calc AY first AT:=(close(0)+high(0)+low(0)+AT)/(3*N); //println "AT":4,AT:8:2,"AY":4, AY:8:2 //Calculate simple MA of absolute value of difference between //current typical price and above AT/AY over N periods DAT:=0;
DAY:=0; //Must use dual calc below since subtracted value is different (AT vs AY) for i=0 to N-1 step 1 do DAT:=DAT+abs((close(-i)+high(-i)+low(-i))/3-AT); DAY:= DAY+abs((close(-i-1)+high(-i-1)+low(-i-1))/3-AY); next i;
if DAT=0 then DAT:=0.0001; else DAT:=DAT/N; endif;
if DAY=0 then DAY:=0.0001; else DAY:=DAY/N; endif;
//Println "DAT":4,DAT:8:2,"DAY":4,DAY:8:2 //Calculate CCI for today CCIT and yesterday CCIY CCIT:= ((close(0)+high(0)+low(0))/3 - AT)/(0.015*DAT); CCIY:= ((close(-1)+high(-1)+low(-1))/3 - AY)/(0.015*DAY); //println symbol:8, "Tod CCI":9, CCIT:8:1,"Yes CCI":9, CCIY:12:1 //Now look for crossover with -150 //if CCIT>-150 and CCIY<-150 then println symbol:-8, "CCI Today":11,CCIT:6:0,"CCI Yesterday":15,CCIY:6:0; //endif;
********************
//CCI crossing up through -150, by Bill Riedeman
output = "ccibill.lst"; exchange nasdaq, nyse, amex;
integer i,N; float CCIT, CCIY, DAT, DAY, AT, AY;
N:=13;
//Number of periods in CCI calculation //Calculate simple MA of typical price for N periods //for Today and Yesterday. AT/AY are running averages.
AT:= 0; for i=1 to N-1 step 1 do AT := AT+close(-i)+high(-i)+low(-i); next i;
AY:=(close(-N)+high(-N)+low(-N)+AT)/(3*N); //Make sure to calc AY first AT:=(close(0)+high(0)+low(0)+AT)/(3*N); //println "AT":4,AT:8:2,"AY":4, AY:8:2 //Calculate simple MA of absolute value of difference between //current typical price and above AT/AY over N periods DAT:=0;
DAY:=0; //Must use dual calc below since subtracted value is different (AT vs AY) for i=0 to N-1 step 1 do DAT:=DAT+abs((close(-i)+high(-i)+low(-i))/3-AT); DAY:= DAY+abs((close(-i-1)+high(-i-1)+low(-i-1))/3-AY); next i;
if DAT=0 then DAT:=0.0001; else DAT:=DAT/N; endif;
if DAY=0 then DAY:=0.0001; else DAY:=DAY/N; endif;
//Println "DAT":4,DAT:8:2,"DAY":4,DAY:8:2 //Calculate CCI for today CCIT and yesterday CCIY CCIT:= ((close(0)+high(0)+low(0))/3 - AT)/(0.015*DAT); CCIY:= ((close(-1)+high(-1)+low(-1))/3 - AY)/(0.015*DAY); //println symbol:8, "Tod CCI":9, CCIT:8:1,"Yes CCI":9, CCIY:12:1 //Now look for crossover with -150 if CCIT>-150 and CCIY<-150 then println symbol:-8, "CCI Today":11,CCIT:6:0,"CCI Yesterday":15,CCIY:6:0; endif; |