FX_Sniper's_Ergodic_CCI_Trigger_002

Download script
FX_Sniper's_Ergodic_CCI_Trigger_002

This technical indicator, designed for the MetaTrader platform, serves as a momentum-based analysis tool that helps traders identify potential shifts in market direction. It works by processing raw price movements through multiple layers of mathematical filtering to smooth out "noise" and highlight significant trends.

How the Logic Works

The script operates by breaking down the price action into several distinct stages:

1. Movement Tracking The foundation of the tool is based on calculating the difference between consecutive closing prices. This allows the indicator to focus on how much the price is moving from one moment to the next, rather than just looking at the absolute price value. It then creates a version of this data that focuses purely on the magnitude of movement (the absolute change), ensuring that both upward and downward movements are accounted for equally in its underlying calculations.

2. Multi-Layer Smoothing To prevent the indicator from reacting to minor, insignificant price fluctuations, the script applies several layers of Exponential Moving Averages (EMA). It processes the data twice:

  • First, it smooths the raw movements.
  • Second, it performs a secondary smoothing on those results. By layering these averages, the tool filters out "jitter" and focuses on the underlying velocity of the market.

3. The Ergodic CCI Calculation The core of the logic combines the smoothed movement data and the smoothed magnitude data into a custom calculation referred to as the "ErgoCCI." This value represents a specialized ratio that interprets the relationship between the strength of the trend and its relative volatility.

4. Signal Generation (The Trigger) Finally, the script applies one last smoothing layer to the ErgoCCI to create what is known as the "Trigger Line." The visual output on your chart provides real-time signals based on the relationship between these two lines:

  • LONG Signal: Occurs when the primary calculated value falls below the Trigger Line.
  • SHORT Signal: Occurs when the primary calculated value rises above the Trigger Line.
  • NEUTRAL Signal: Occurs when both values are equal, suggesting a state of balance or transition.

Summary for the Trader

In plain terms, this tool acts as a sophisticated "momentum filter." It observes how fast and in what direction the market is moving, smooths out the chaotic ups and downs of price action, and provides a visual cue when the momentum shifts significantly enough to suggest a new trend.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
FX_Sniper's_Ergodic_CCI_Trigger_002
//+------------------------------------------------------------------+
//|                                       Louw Coetzer aka FX Sniper |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, Fx Sniper."
#property  link      "http://www.dunno.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Aqua
#property  indicator_color2  Red


// Ergo Variables

extern int pq =2;
extern int pr = 10;
extern int ps = 1;
extern int trigger =2;

//---- indicator buffers

string signal;
double mtm[];
double absmtm[];
double ErgoCCI[];
double MainCCI[];
double var1[];
double var2[];
double var2a[];
double var2b[];
//double valor1[];
//double valor2[];
//double extvar[];
//double cciSignal[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(8);
   
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,Aqua);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,Red);
   
   SetIndexBuffer(0,ErgoCCI);
   SetIndexLabel(0,"Egodic CCI");
   SetIndexBuffer(1,MainCCI);
   SetIndexLabel(1,"Trigger Line");
   SetIndexBuffer(2,mtm);
   SetIndexBuffer(3,var1);
   SetIndexBuffer(4,var2);
   SetIndexBuffer(5,absmtm);
   SetIndexBuffer(6,var2a);
   SetIndexBuffer(7,var2b);
      
//---- name for DataWindow and indicator subwindow label

   
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Calculations                                    |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int i;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
 
//---- main loop
   
//---- done

   for(i=0; i <= Bars; i++) 
   {
   mtm[i]= Close[i]- Close[i +1];
   }
   for(i=0; i <= Bars-1; i++) 
   { 
    absmtm[i] =  MathAbs(mtm[i]);
   }
   for(i=0; i <= Bars-1; i++) 
   {   
    var1[i]= iMAOnArray(mtm,0,pq,0,MODE_EMA,i);
   }
   for(i=0; i <= Bars-1; i++) 
   {
   var2[i]= iMAOnArray(var1,Bars,pr,0,MODE_EMA,i);
   }
   for(i=0; i <= Bars-1; i++) 
   {
   var2a[i]= iMAOnArray(absmtm,0,pq,0,MODE_EMA,i);
   }
   for(i=0; i <= Bars-1; i++) 
   {
   var2b[i]= iMAOnArray(var2a,0,pr,0,MODE_EMA,i);
   }
    for(i=0; i <= Bars-1; i++) 
   {   
   ErgoCCI[i] = (500 * iMAOnArray(var2,0,ps,0,MODE_EMA,i))/(iMAOnArray(var2b,0,ps,0,MODE_EMA,i)); //var2a[i]/var2b[i];
   
   }
   for(i=0; i<=Bars; i++)
   {
     MainCCI[i]=iMAOnArray(ErgoCCI,0,trigger,0,MODE_EMA,i);
   }
   
   for(i=0; i<=Bars; i++)
   {
      if(MainCCI[i] > ErgoCCI[i])
      {signal = "SHORT";}
      if (MainCCI[i] < ErgoCCI[i])
      {signal = "LONG";}
      if (MainCCI[i] == ErgoCCI[i])
      {signal = "NEUTRAL";}
 
    IndicatorShortName("FX Sniper's Ergodic CCI & Trigger: "+signal);
   return(0); }
  }
//+------------------------------------------------------------------+

Comments