CCI_onMA_SmzSigMA

CCI_onMA_SmzSigMA

This custom indicator is designed to provide a multi-layered analysis of market trends by combining momentum tracking with smoothed moving averages. Instead of looking at price action in isolation, the script processes data through several "filters" to help identify underlying trends and potential shifts in market direction.

Core Logic and Data Processing

The tool functions by layering three distinct types of calculations on top of one another:

1. The Foundation: Momentum and Trend Blend The script begins by calculating two primary values: a Commodity Channel Index (CCI), which measures the current price relative to its average over a specific period (momentum), and a Moving Average (MA), which represents the general trend of the price.

Rather than showing these separately, the script combines them. It takes the momentum value, scales it down using a specific multiplier, and adds it to the moving average. This creates a "hybrid" line that reacts to both the immediate strength of the market (momentum) and its broader direction (trend).

2. The First Smoothing Layer (SmzMA) Once the hybrid line is created, the script doesn't display it immediately. Instead, it applies a second moving average specifically to that hybrid data. This acts as a "smoothing" filter. By calculating a moving average on top of the previous calculation, the indicator removes "noise"—the small, jagged fluctuations that can often lead to false signals in volatile markets.

3. The Final Signal Layer (SigMA) The final step in the logic is the application of a third moving average. This is applied to the already smoothed data from the previous step. This creates a "Signal" line. By the time the data reaches this stage, it has been processed through three different mathematical filters.

How it appears on your chart

The result is a sophisticated visual output where:

  • The Hybrid Line shows the raw interaction between momentum and trend.
  • The Smoothed Lines provide a stabilized view of that interaction.

By following this "nested" logic (calculating an average of an average of a hybrid value), the tool aims to provide a clearer picture of market flow, helping traders distinguish between temporary price spikes and sustained directional moves.

Indicators Used
Commodity channel indexMoving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
CCI_onMA_SmzSigMA
//+------------------------------------------------------------------+
//|CCI_onMA_2SigMA                                      CCI_onMA.mq4 |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
//2008forextsd   ki
#property copyright "http://www.forex-tsd.com/"
#property link    ""  

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Purple
#property indicator_color2 RoyalBlue
#property indicator_color3 Red
#property indicator_color4 Orange

#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 2
#property indicator_width4 1

//---- 
extern int CCI_Period   = 14;
extern int CCI_Price    = 5;
extern double CCI_multiplier = 0.3;
extern bool Show_CCI    = true;



extern int MaPeriod     = 14;
extern int MaMetod      = 0;
extern int MaPrice      = 5;
extern bool Show_MA     = true;

extern int SmzMaPeriod     = 5;
extern int SmzMaMetod      = 1;  
extern bool Show_SmzMA     = true;

extern int SigMaPeriod     = 8;
extern int SigMaMetod      = 1;  
extern bool Show_SigMA     = true;



//SigMaPrice close only (onArray);

extern string   note_Price = "0C,1O 2H3L,4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
extern string   MA_Method_ = "SMA0 EMA1 SMMA2 LWMA3";

//---- 

double CCIonMABuffer[];
double MA_Buffer[];
double SmzMA_Buffer[];

double SigMA_Buffer[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//|------------------------------------------------------------------|

int init()
  {
//---- 
   IndicatorBuffers(4);
   
   SetIndexBuffer(0, CCIonMABuffer);
   SetIndexBuffer(1, MA_Buffer);
   SetIndexBuffer(2, SmzMA_Buffer);
   SetIndexBuffer(3, SigMA_Buffer);
   

   SetIndexStyle(0,DRAW_NONE); if (Show_CCI)    SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_NONE); if (Show_MA)     SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_NONE); if (Show_SmzMA)  SetIndexStyle(2,DRAW_LINE);
   SetIndexStyle(3,DRAW_NONE); if (Show_SigMA)  SetIndexStyle(3,DRAW_LINE);



//----    


   SetIndexLabel(0,"CCIonMA CCI:("+CCI_Period+"|"+CCI_Price+")");
   SetIndexLabel(1,"MA     ("+MaPeriod+")"+MaMetod+","+MaPrice+"");
   SetIndexLabel(2,"SmzMA  ("+SmzMaPeriod+")"+SmzMaMetod+"");
   SetIndexLabel(3,"SigMA  ("+SigMaPeriod+")"+SigMaMetod+"");


   IndicatorShortName("CCIonMA ("+CCI_Period+") "+MaPeriod+"|"+SigMaPeriod+"|");

    int  max= MathMax (MaPeriod,CCI_Period); 
         max= MathMax (max,SmzMaPeriod);
         max= MathMax (max,SigMaPeriod);

    for (int i=0;i<indicator_buffers;i++) 
    SetIndexDrawBegin (i,max);   

   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
 


   int    i,limit,    countedBars=IndicatorCounted();
   if (countedBars<0) return(-1);
   if (countedBars>0) countedBars--;

      limit= Bars-countedBars;
      limit= MathMax(limit,CCI_Period);
      limit= MathMax(limit,MaPeriod);
      limit= MathMax(limit,SmzMaPeriod);
      limit= MathMax(limit,SigMaPeriod);


      for (i=limit;i>=0;i--)

     {

   double     CCI_val   =  iCCI(NULL,0,CCI_Period,CCI_Price,i);
   MA_Buffer      [i]   =  iMA(NULL,0,MaPeriod,0,MaMetod,MaPrice,i);
   CCIonMABuffer  [i]   =  CCI_val*CCI_multiplier*Point+ MA_Buffer[i];

      }
     
      for (i=limit;i>=0;i--)
      
   SmzMA_Buffer[i]=iMAOnArray(CCIonMABuffer,0,SmzMaPeriod,0,SmzMaMetod,i);

     
      for (i=limit;i>=0;i--)

   SigMA_Buffer[i]=iMAOnArray(SmzMA_Buffer,0,SigMaPeriod,0,SigMaMetod,i);





   return(0);
 }
//+------------------------------------------------------------------+

Comments