I think the first thing that needs to be done here is to look at what this indicator really is. Maybe see if it really is a magic indicator, or if not, take some of the magic and mystery out of it. If you look at the code it only consists of a few lines.
Here�s the code:
Code:
1. Calculate the Typical Price = (High + Low + Close) / 3
2. Calculate the simple moving average item #1. We�ll call it SMATP.
3. Calculate the Mean Deviation: delta_i = abs(last_SMATP � TP_of_period_i) (for all i from 0 to N, where N is the length of a period used to calculate the SMATP). MD = sum_for_all_i(delta_i) / N
4. Calculate the CCI = (TP � SMATP) / (0.015 * MD)
A close approximation of the CCI can be replicated easily by the use of Bollinger Bands.
In the above chart we again have the CCI (20) in the bottom subgraph, and I have returned the non-detrended typical price [ ( H+L+C)/3 ] line along with the 20 period simple moving average. I added the Bollinger Bands.
The zero line of CCI is the same as the moving average
and is coded as yellow.
I plotted to Bollinger Bands as a dashed grey line so it can easily be referenced to the plus 100 and minus 100 CCI reference lines. I�m sure my estimation isn�t perfect. I wasn�t trying to get a perfect match. But you can see it is very close. So close that for all practical purposes it is the same. Just look at the excursions outside the CCI bands and then refer to the same spot on the Bollinger Bands.
Now the 100 lines are accounted for.