cci_filter

This tool is designed to provide traders with a smoother, more refined visual representation of market momentum by layering two different types of mathematical filters. Instead of showing raw, jagged price movements, it processes the data twice to identify clearer trends and reduce "market noise."

How the Logic Works

The script operates in two distinct stages to arrive at its final result:

1. The Momentum Foundation (CCI) First, the tool calculates a standard technical indicator known as the Commodity Channel Index (CCI). This specific metric measures how far the current price is deviating from its average over a set period of time. By looking at this first, the script identifies whether the market is currently trending strongly in one direction or if it is experiencing significant fluctuations.

2. The Smoothing Filter (Moving Average) Because raw momentum data can often be erratic and jump around quickly, the script then applies a secondary layer of processing. It takes all the data generated in the first step and runs it through a Moving Average calculation.

The Final Result for the Trader

Instead of simply showing you the raw CCI (which can change rapidly), this script shows you the average of that momentum. By applying this "Filter," the tool produces a much steadier line on your chart. This helps in identifying the underlying trend of the market's momentum, making it easier to see whether the overall strength of a move is sustaining or beginning to weaken, without being distracted by minor, temporary price spikes.

Indicators Used
Commodity channel indexMoving average indicator
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
cci_filter
//+------------------------------------------------------------------+
//|                                                   CCI_Filter.mq4 |
//+------------------------------------------------------------------+
//|                                                   CCI_Filter.mq4 |
//|                          Copyright 2014, Toptahlil Software Corp |
//|                                      Emial : Toptahlil@yahoo.com |
//+------------------------------------------------------------------+
#property description "feedbacks: https://login.mql5.com/en/users/toptahlil/feedbacks"
#property copyright  "post a job for me: http://www.mql5.com/en/job/new?prefered=toptahlil"
#property link      "Emial : Toptahlil@yahoo.com"
#property description      "Skype ID : Toptahlil"
#property description      "MQL5  ID : Toptahlil"
#property version   "1.0"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red


extern int CCI_Period=34;
extern ENUM_APPLIED_PRICE CCI_ApplyPrice=PRICE_CLOSE;
extern int MA_Period=34;
extern  ENUM_MA_METHOD MA_Method=MODE_SMMA;
extern int MA_Shift=0;
double B1[],B2[],B3[];

//----
int ExtCountedBars=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0,B1);
   SetIndexBuffer(1,B2);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- indicator short name
   IndicatorShortName("CCI_Filter");
   ArraySetAsSeries(B1,true);
   ArraySetAsSeries(B2,true);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

   int    pos=Bars-2;
   int i;
   if(ExtCountedBars>2) pos=Bars-ExtCountedBars-1;
//---- main calculation loop
   for(i=0;i<Bars;i++)
     {
      B1[i]=iCCI(Symbol(),Period(),CCI_Period,CCI_ApplyPrice,i);
     }
   for(i=0;i<Bars;i++)
     {

      B2[i]=iMAOnArray(B1,0,MA_Period,MA_Shift,MA_Method,i);
     }
   return(0);
  }

//+------------------------------------------------------------------+

Comments