Attached is an AFL file displaying 2 CCI's:

1) a variable period CCI ranging between 0 - 100
2) a standard CCI(20) ranging between    0 - 100.

You'll need at least 200 bars of data for it to work.

Hope you can use this. :-)

wayne

MarketMonk777 wrote:

Pretty fancy graphics you have attached.  
 
 
This is a classic engineering problem involving rescaling one range to another.
 
The basic equation is:
 
Y = mX = b where
Y is the CCI_N (CCI New 0-100 range)
m is the slope
X is the CCI_O (CCI Old -100 to 100 range)
b is the y offset
 
Is goes that the New CCI is what we want so it is on the Y axis and the old CCI is what we have and it goes on the X axis.
 
So the slope is the change in Y over the change is X or:
Delta Y = 100 - 0 or 100
Delta X = 100 - (-100) or 200
so m = 100/200 or 1/2 or .5
 
the Y offset is the value when x=0 (where does the line cross the Y axis) which is 50.
 
so the equation is:
 
CCI_N = ( .5 * CCI_O ) + 50
 
To test this let's plug in some numbers.
 
CCI_O = -100
 
CCI_N = .5*(-100) + 50
          = -50 + 50
          = 0
 
CCI_O = +100
 
CCI_N = .5 * (+100)  + 50
          = +50  + 50
          = +100
 
So all you have to do is take the standard CCI indicator and rescale it to the new CCI_N range and plot that instead.
 
Regards,
 
Dave


From: [email protected] [mailto:[email protected]] On Behalf Of mrdavis9
Sent: Monday, July 10, 2006 6:52 PM
To: [email protected]
Subject: [amibroker] Want CCI to range from 0 to 100

I would like to have a CCI(50) , and also a CCI(100) that ranges from Zero to 100, in lieu of the typical CCI range of negative 100 to positive 100.
 
This formula balow comes from Investor/RT Tour
 
====================
TP = (HI + LO + CL) / 3
    TP stands for Typical Price

MATP = MA(TP, n)
    n = CCI Period
    MATP stands for Moving Average (Simple) of Typical Price


    where n = CCI Period
    MDTP stands for Mean Deviation of Typical Price
 

CCI = (TP - MATP) / (MDTP * 0.015)
=====================================
I bet that Dingo knows how to  change this formula so that  it will oscillate between zero and 100.
 
Later Ron D.
 
_SECTION_BEGIN("CCIvariable");

function MeanDev( array, mean, range )
{
  result = 0;

   for( i = LastValue( range ) ; i < BarCount; i++ )
   {
      result[ i ] = 0;

      // the mean is not 'moving' over the range (outside the loop)
      tm = mean[ i ];

      for( j = 0; j < range[ i ] AND ( i - j ) >= 0 AND ( i - j ) < BarCount; 
j++ )
      {
        result[ i ] = result[ i ] + abs( array[ i - j ] - tm );
      }
    
    result[ i ] = result[ i ]/range[ i ];
  }
  
  return result;
}

function VarCCI( array, period )
{

 SMATP = MA(array,period );//1,2

 MD = MeanDev( array, SMATP, period  );

 CCIx = (Avg - SMATP) / (0.015 * MD);

 return CCIx;

}

n = 20 + 4 * sin( Cum(1) ); // variable period
CCIv= VarCCI(Avg,n);

CCIvar= 100 * (CCIv  -  LLV(CCIv,200))/(HHV(CCIv,200)  -  LLV(CCIv,200));
CCIstd= 100 * (CCI(20)  -  LLV(CCI(20),200))/(HHV(CCI(20),200)  -  
LLV(CCI(20),200));

Plot(CCIvar,"CCIvar",colorGreen,styleLine);

Plot(CCIstd,"CCIstd",colorRed,styleLine); 

PlotGrid(50,55);

_SECTION_END();

Reply via email to