[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CCI Function



PureBytes Links

Trading Reference Links

At 10:07 AM 3/1/2005, Joe S wrote:

>Could someone please send me the text (not an ELD or ELS) of the CCI function included in Tradestation 8?

Here it is.

Bob Fulks

------------------------



{ Commodity Channel Index }

inputs: 
        Length( numericsimple ) ;  { will get divide-by-zero error if Length = 0 }

variables:      
        Mean( 0 ), 
        AvgDev( 0 ), 
        Counter( 0 ) ;

Mean = Average( H + L + C, Length ) ; { don't have to divide H+L+C by 3, cancels out } 
AvgDev = 0 ;
for Counter = 0 to Length - 1 
        begin
        AvgDev = AvgDev + AbsValue( ( H + L + C )[Counter] - Mean ) ;
        end ;
AvgDev = AvgDev / Length ;

if AvgDev = 0 then
        CCI = 0
else
        CCI = ( H + L + C - Mean ) / ( .015 * AvgDev ) ;


{ ** Copyright (c) 1991-2003 TradeStation Technologies, Inc. All rights reserved. ** 
  ** TradeStation reserves the right to modify or overwrite this analysis technique 
     with each release. ** }