This indicator is designed to provide a comprehensive view of market momentum by simultaneously tracking multiple timeframe cycles in a single visual window. Rather than relying on a single data point, it uses a "multi-layered" approach to help traders identify trends across different speeds of price action.
Core Functionality
The script calculates the Commodity Channel Index (CCI)—a standard technical analysis tool used to measure the current price relative to its average over a specific period—across eight distinct time horizons at once. By visualizing these eight different periods simultaneously, the tool allows you to see how the market is behaving in both the short term and the long term.
How it Works
The logic follows a structured process to ensure clarity and accuracy on your chart:
- Multi-Period Analysis: The indicator processes eight unique settings (ranging from very fast, short-term cycles to slower, broader cycles). Each of these periods is assigned its own dedicated color on the screen.
- Data Synchronization: For every new price movement, the script calculates the CCI for all eight periods simultaneously. This ensures that when you look at a specific point in time, you can see how all eight "speeds" of the market are reacting to that exact moment.
- Standardized Calculation: All calculations are based on "Typical Price," which is a balanced calculation involving the high, low, and closing prices of a candle. This provides a more stable and representative view of price movement than using just a single price point.
- Visual Layering: Each period is plotted as an individual line. This creates a visual "bundle" of information. When these lines move in the same direction, it can suggest strong trend agreement; when they diverge or cross one another, it provides a clearer picture of where momentum is shifting or losing steam.
Key Benefits for the User
Instead of having to switch between different indicators or different chart settings to see what "short-term" vs. "long-term" traders are seeing, this tool consolidates that information into one view. It allows you to observe:
- Trend Convergence: Identifying when multiple timeframes align in the same direction.
- Volatility Shifts: Spotting where fast-moving cycles break away from slower, established trends.
- Market Harmony: Getting a holistic "pulse" of the market's current energy at a glance.
//+------------------------------------------------------------------+
//| FXVolatility.com / Mark Whistler
//| with ECTrader.net
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Orange
#property indicator_color3 Gold
#property indicator_color4 Lime
#property indicator_color5 Aqua
#property indicator_color6 DodgerBlue
#property indicator_color7 MediumPurple
#property indicator_color8 Silver
#property indicator_level1 0
#property indicator_levelcolor LightSlateGray
//---- input parameters
extern int CCIPeriod1 = 5;
extern int CCIPeriod2 = 7;
extern int CCIPeriod3 = 9;
extern int CCIPeriod4 = 11;
extern int CCIPeriod5 = 14;
extern int CCIPeriod6 = 17;
extern int CCIPeriod7 = 20;
extern int CCIPeriod8 = 23;
//---- buffers
double CCIBuffer1[];
double CCIBuffer2[];
double CCIBuffer3[];
double CCIBuffer4[];
double CCIBuffer5[];
double CCIBuffer6[];
double CCIBuffer7[];
double CCIBuffer8[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
SetIndexStyle(0, DRAW_LINE);
SetIndexStyle(1, DRAW_LINE);
SetIndexStyle(2, DRAW_LINE);
SetIndexStyle(3, DRAW_LINE);
SetIndexStyle(4, DRAW_LINE);
SetIndexStyle(5, DRAW_LINE);
SetIndexStyle(6, DRAW_LINE);
SetIndexStyle(7, DRAW_LINE);
SetIndexBuffer(0, CCIBuffer1);
SetIndexBuffer(1, CCIBuffer2);
SetIndexBuffer(2, CCIBuffer3);
SetIndexBuffer(3, CCIBuffer4);
SetIndexBuffer(4, CCIBuffer5);
SetIndexBuffer(5, CCIBuffer6);
SetIndexBuffer(6, CCIBuffer7);
SetIndexBuffer(7, CCIBuffer8);
//---- name for DataWindow and indicator subwindow label
short_name = "Multi CCI on " + " (" + CCIPeriod1 + ", " + CCIPeriod2 + ", " + CCIPeriod3 + " , " + CCIPeriod4 + " , " + CCIPeriod5 + " , " + CCIPeriod6 + " , " + CCIPeriod7 + " , " + CCIPeriod8 + " )";
IndicatorShortName(short_name);
SetIndexLabel(0, "Multi CCI(" + CCIPeriod1 + ")");
SetIndexLabel(1, "Multi CCI(" + CCIPeriod2 + ")");
SetIndexLabel(2, "Multi CCI(" + CCIPeriod3 + ")");
SetIndexLabel(3, "Multi CCI(" + CCIPeriod4 + ")");
SetIndexLabel(4, "Multi CCI(" + CCIPeriod5 + ")");
SetIndexLabel(5, "Multi CCI(" + CCIPeriod6 + ")");
SetIndexLabel(6, "Multi CCI(" + CCIPeriod7 + ")");
SetIndexLabel(7, "Multi CCI(" + CCIPeriod8 + ")");
//----
SetIndexDrawBegin(0, CCIPeriod1);
SetIndexDrawBegin(1, CCIPeriod2);
SetIndexDrawBegin(2, CCIPeriod3);
SetIndexDrawBegin(3, CCIPeriod4);
SetIndexDrawBegin(4, CCIPeriod5);
SetIndexDrawBegin(5, CCIPeriod6);
SetIndexDrawBegin(6, CCIPeriod7);
SetIndexDrawBegin(7, CCIPeriod8);
//----
return(0);
}
//+------------------------------------------------------------------+
//| CCI_Periods |
//+------------------------------------------------------------------+
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);
CCIBuffer3[i] = iCCI(NULL, 0, CCIPeriod3, PRICE_TYPICAL, i);
CCIBuffer4[i] = iCCI(NULL, 0, CCIPeriod4, PRICE_TYPICAL, i);
CCIBuffer5[i] = iCCI(NULL, 0, CCIPeriod5, PRICE_TYPICAL, i);
CCIBuffer6[i] = iCCI(NULL, 0, CCIPeriod6, PRICE_TYPICAL, i);
CCIBuffer7[i] = iCCI(NULL, 0, CCIPeriod7, PRICE_TYPICAL, i);
CCIBuffer8[i] = iCCI(NULL, 0, CCIPeriod8, PRICE_TYPICAL, i);
i--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments