FX_Snipers_Ergodic_CCI_Trigger

Download script
FX_Snipers_Ergodic_CCI_Trigger

This tool, known as the "FX Sniper's Ergodic CCI & Trigger," is a specialized technical analysis indicator designed to help traders identify potential trends and momentum shifts in the market. Rather than looking at simple price movements, it uses a multi-layered mathematical approach to smooth out market "noise" and highlight significant price actions.

How the Logic Works

The script processes market data through several distinct stages to arrive at a final visual signal:

1. Momentum Measurement The logic begins by calculating the difference between the current closing price and the previous closing price. It then takes the absolute value of these differences to measure the "strength" of the movement, regardless of whether the price went up or down.

2. Multi-Layered Smoothing To prevent the indicator from reacting too wildly to minor price fluctuations, the script applies several rounds of Exponential Moving Averages (EMA). It smooths out both the direction of the price and the intensity of the movements across multiple levels. This creates a stabilized view of the market's underlying energy.

3. The Ergodic CCI Calculation The core of the tool is a custom calculation that compares these smoothed momentum values against the smoothed intensity values. By dividing the "direction" component by the "intensity" component and applying a multiplier, the script produces the ErgoCCI line. This represents the normalized velocity of the market trend.

4. The Trigger System Finally, the script calculates a Trigger Line, which is an additional smoothing average of the ErgoCCI. The interaction between these two lines provides the primary visual cues for the user:

  • Long Signal: Generated when the main trigger line falls below the ErgoCCI.
  • Short Signal: Generated when the main trigger line rises above the ErgoCCI.
  • Neutral Signal: Indicates a state of equilibrium when the two lines meet or overlap.

Summary for the User

Essentially, this script acts as a momentum filter. It strips away the "jitter" of the live market to reveal whether the current trend has enough strength to sustain itself. By observing the relationship between the blue and red lines on your chart, you can visually identify moments where the market momentum is shifting in favor of a specific direction.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
15 Views
0 Downloads
0 Favorites
FX_Snipers_Ergodic_CCI_Trigger
//+------------------------------------------------------------------+
//|                                       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  Blue
#property  indicator_color2  Red


// Ergo Variables

extern int pq =2;
extern int pr = 10;
extern int ps = 5;
extern int trigger =3;

//---- 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,2,Blue);
   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=limit; i >= 0; i--) 
   {
   mtm[i]= Close[i]- Close[i +1];
   }
   for(i=limit; i >= 0; i--) 
   { 
    absmtm[i] =  MathAbs(mtm[i]);
   }
   for(i=limit; i >= 0; i--) 
   {   
    var1[i]= iMAOnArray(mtm,0,pq,0,MODE_EMA,i);
   }
   for(i=limit; i >= 0; i--) 
   {
   var2[i]= iMAOnArray(var1,0,pr,0,MODE_EMA,i);
   }
   for(i=limit; i >= 0; i--) 
   {
   var2a[i]= iMAOnArray(absmtm,0,pq,0,MODE_EMA,i);
   }
   for(i=limit; i >= 0; i--) 
   {
   var2b[i]= iMAOnArray(var2a,0,pr,0,MODE_EMA,i);
   }
    for(i=limit; i >= 0; i--) 
   {   
   if(iMAOnArray(var2b,0,ps,0,MODE_EMA,i)!=0)
   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=limit; i>=0; i--)
   {
     MainCCI[i]=iMAOnArray(ErgoCCI,0,trigger,0,MODE_EMA,i);
   }
   
   for(i=limit; i>=0; 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