Overview
The Commodity Channel Index compares prices with their moving averages. If the Commodity channel index is high, it means that a price is higher than its moving average, which is an indicator that the security is overbought. If the Commodity channel index is low, it means that a price is lower than its moving average, which is an indicator that the security is oversold.
Note |
---|
We recommend that you read Using Financial Formulas before proceeding any further. Using Financial Formulas provides a detailed explanation on how to use formulas, and also explains the various options available to you when applying a formula. |
Figure 1: This chart shows Commodity Channel Index on the lower chart area. The High, Low and Close prices are plotted on the upper chart area as a stock chart. |
Applying a Commodity Channel Index
All formulas are calculated using the FormulaFinancial method, which accepts the following arguments: a formula name; input value(s); output value(s), and parameter(s) that are specific to the type of formula being applied.
Before applying the FormulaFinancial method, make sure that all data points have their XValue property set, and that their series' XValueIndexed property is set to false.
The following table indicates what sort of FormulaFinancial method arguments to use when calculating a Commodity Channel Index, and also supplies a description of what these parameters mean:
Parameter |
Value/Description |
Example |
Formula Name: |
CommodityChannelIndex
|
FormulaFinancial(FinancialFormula.CommodityChannelIndex,"15", Series1:Y,Series1:Y2,Series1:Y4","Series3:Y") |
Input Values: |
Value #1: The value which represents the High price. By default it is the first Y value in the stock chart .
Value #3: The value which represents the Close price. By default it is the fourth Y value in the stock chart. |
FormulaFinancial(FinancialFormula.CommodityChannelIndex,"15", Series1:Y,Series1:Y2,Series1:Y4","Series3:Y") |
Output Value: (optional) |
The Commodity Channel Index indicator. If not specified output is stored in the first input value. |
FormulaFinancial(FinancialFormula.CommodityChannelIndex,"15", Series1:Y,Series1:Y2,Series1:Y4","Series3:Y") |
Parameter: |
Periods, used to calculate the Commodity Channel Index (Default value is 10). |
FormulaFinancial(FinancialFormula.CommodityChannelIndex,"15", Series1:Y,Series1:Y2,Series1:Y4","Series3:Y") |
A line chart is a good choice when displaying a Commodity Channel Index series.
Financial interpretation: The Commodity channel index could be used as an overbought/oversold indicator or for divergence. If the Commodity channel index is high it means that a price is higher than its moving average which is an indicator that security is overbought. If the Commodity channel index is low it means that a price is lower than its moving average, which is an indicator that security is oversold.
If the commodity channel index is above 100 it means that security is overbought. If the commodity channel index is below -100 it means that security is oversold.
Calculation: The Commodity Channel index is calculated using following algorithm:
1. Calculate typical price:
TP = (High+Low+Close) / 3
2. Calculate Simple Moving Average of the TP (SMATP):
SMATP=SMA(TP)
3. Calculate Mean Deviation:
4. Calculate Commodity Channel Index:
Example
This example demonstrates how to calculate Commodity channel index.
Visual Basic | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
|