CCI_Woodies
Download scriptThis tool is a technical analysis indicator designed to help traders visualize price momentum by comparing two different time horizons simultaneously. Rather than looking at the raw price of an asset, it interprets the "velocity" and "strength" of market movements using a specialized mathematical calculation known as the Commodity Channel Index (CCI).
Core Logic and Functionality
The script operates by calculating two distinct layers of data and displaying them in a separate window below your main trading chart. Here is how the logic flows:
1. Multi-Horizon Analysis The indicator doesn't just provide one perspective; it processes market data through two different timeframes at once.
- The Primary View: It calculates a standard momentum cycle based on a longer period (defaulting to 14 units). This helps identify the broader, "slow" trends in the market.
- The Secondary View: It simultaneously calculates a much faster momentum cycle based on a shorter period (defaulting to 6 units). This allows you to see immediate, "quick" fluctuations and reactions to news or price spikes.
2. Momentum Tracking The logic relies on "Typical Price"—a calculation that averages the high, low, and closing prices of each candle. By using this average instead of just the closing price, the indicator provides a more balanced view of where the market is actually moving, filtering out some of the "noise" from erratic price spikes.
3. Visual Interpretation The script renders these two calculations as distinct lines on your screen:
- The SteelBlue line represents the primary, longer-term momentum.
- The Red line represents the faster, shorter-term momentum.
How This Benefits the Trader
By overlaying these two lines, the logic allows a visitor to see the relationship between short-term volatility and long-term trends. When both lines move in harmony, it suggests a strong, unified market direction. Conversely, when the lines diverge (for example, if the fast red line spikes while the blue line remains flat), it alerts the trader to immediate instability or potential changes in momentum before they become obvious on the main price chart.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| CCI_Woodies.mq4 |
//| |
//| |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 SteelBlue
#property indicator_color2 Red
//---- input parameters
extern int CCIPeriod1=14;
extern int CCIPeriod2=6;
//---- buffers
double CCIBuffer1[];
double CCIBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,SteelBlue);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(0,CCIBuffer1);
SetIndexBuffer(1,CCIBuffer2);
//----
SetIndexDrawBegin(0,CCIPeriod1);
SetIndexDrawBegin(1,CCIPeriod1);
//----
return(0);
}
//+------------------------------------------------------------------+
//| CCI_Woodies |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
//----
if(Bars<=CCIPeriod1) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=CCIPeriod1;i++) CCIBuffer1[Bars-i]=0.0;
//----
i=Bars-CCIPeriod1-1;
if(counted_bars>=CCIPeriod1) i=Bars-counted_bars-1;
while(i>=0)
{
CCIBuffer1[i]=iCCI(NULL,0,CCIPeriod1,PRICE_TYPICAL,i);
CCIBuffer2[i]=iCCI(NULL,0,CCIPeriod2,PRICE_TYPICAL,i);
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments