To: TechTrader42 who wrote (3122 ) 1/18/1998 11:06:00 PM From: TechTrader42 Read Replies (1) | Respond to of 11149
Here's a CCI scan that shows the sort of dilemma a TA dilettante can get into, however diligent. This scan gives values for CCI(3), (5), (8) and (13), depending on what you put in for periods. There is one variable in it that I find to be the toughest to reduce so the formula can use any periods. This variable is called "second" in my scan, because it's the second main part of the CCI formula. You can see that "second" grows in length, depending on the periods you select. If you select 3 days, for example, "second" has to look back three days. But it's the most complicated line in the formula for CCI, I find, and I've tried all sorts of for loops to reduce it, but invariably (well, actually variably, in this case), I wind up distorting the value of CCI. As the scan is, the values match those in WOW. If any of you for loopers want to take a look at "second," I'd be forever grateful. Here's the scan -- and if scans can be phrased as questions -- this one certainly is: //CCI(13) -- calculate values output="ccivar.lst"; daystoload = 250; float periods, cci, first, second, total, B, aa; integer days; periods:=13; //PICK 3, 5, 8 or 13 B :=(high(0)+low(0)+close(0))/periods; aa:=0; for days=0 to -(periods-1) step -1 do aa:=aa+((high(days)+low(days)+close(days))/periods)/periods; next days; second:=0; first:=0; total:=0; if periods=3 then for days=0 to -(periods-1) step -1 do second:= ((high(days)+low(days)+close(days))/periods + (high(days-1)+low(days-1)+close(days-1))/periods + (high(days-2)+low(days-2)+close(days-2))/periods)/periods; first:=(high(days)+low(days)+close(days))/periods; total:=total+abs(first-second); next days; endif; if periods=5 then for days=0 to -(periods-1) step -1 do second:= ((high(days)+low(days)+close(days))/periods + (high(days-1)+low(days-1)+close(days-1))/periods + (high(days-2)+low(days-2)+close(days-2))/periods+ (high(days-3)+low(days-3)+close(days-3))/periods+ (high(days-4)+low(days-4)+close(days-4))/periods)/periods; first:=(high(days)+low(days)+close(days))/periods; total:=total+abs(first-second); next days; endif; if periods=8 then for days=0 to -(periods-1) step -1 do second:= ((high(days)+low(days)+close(days))/periods + (high(days-1)+low(days-1)+close(days-1))/periods + (high(days-2)+low(days-2)+close(days-2))/periods+ (high(days-3)+low(days-3)+close(days-3))/periods+ (high(days-4)+low(days-4)+close(days-4))/periods+(high(days-5)+low(days-5)+close(days-5))/periods + (high(days-6)+low(days-6)+close(days-6))/periods + (high(days-7)+low(days-7)+close(days-7))/periods)/periods; first:=(high(days)+low(days)+close(days))/periods; total:=total+abs(first-second); next days; endif; cci:=(B-aa)/(0.015*(total)/periods+.00001); if periods=13 then for days=0 to -(periods-1) step -1 do second:= ((high(days)+low(days)+close(days))/periods + (high(days-1)+low(days-1)+close(days-1))/periods + (high(days-2)+low(days-2)+close(days-2))/periods+ (high(days-3)+low(days-3)+close(days-3))/periods+ (high(days-4)+low(days-4)+close(days-4))/periods+(high(days-5)+low(days-5)+close(days-5))/periods + (high(days-6)+low(days-6)+close(days-6))/periods + (high(days-7)+low(days-7)+close(days-7))/periods+ (high(days-8)+low(days-8)+close(days-8))/periods+ (high(days-9)+low(days-9)+close(days-9))/periods+(high(days-10)+low(days-10)+close(days-10))/periods + (high(days-11)+low(days-11)+close(days-11))/periods + (high(days-12)+low(days-12)+close(days-12))/periods)/periods; first:=(high(days)+low(days)+close(days))/periods; total:=total+abs(first-second); next days; endif; cci:=(B-aa)/(0.015*(total)/periods+.00001); Println Symbol, ": ", cci:8:2;