FXSnipersErgodic_CCITrigger

Download script
FXSnipersErgodic_CCITrigger

This tool is designed as a specialized technical indicator for the MetaTrader platform, primarily used to identify momentum shifts and potential trading opportunities by analyzing price movement patterns. Instead of looking at simple price action alone, it uses a multi-layered mathematical approach to smooth out market "noise" and highlight underlying trends.

How the Logic Works

The script operates through a series of sequential data processing steps:

1. Momentum Tracking The core logic begins by calculating the "Momentum" of the market. It does this by measuring the difference between current closing prices and previous closing prices. This helps the tool understand the velocity at which the price is moving.

2. Smoothing and Magnitude Analysis To prevent erratic price spikes from creating false signals, the script performs several layers of smoothing:

  • It calculates the absolute value of these momentum movements (focusing on the strength of the move, regardless of direction).
  • It applies "Exponential Moving Averages" (EMA) to these values. By layering multiple averages over each other, the script creates a stabilized view of the market's current energy levels.

3. The Ergodic CCI Calculation The tool combines these smoothed components into what is called the "ErgoCCI." This is essentially a ratio: it compares the smoothed momentum of the price against its own historical average magnitude. By calculating this relationship, the indicator attempts to determine if the current market strength is significantly higher or lower than what is typical for that specific period.

4. The Trigger Mechanism Finally, the script applies one last layer of smoothing to the ErgoCCI to create a "Trigger Line." This acts as a visual guide to confirm the trend.

Trading Signals

The interaction between the ErgoCCI line and the Trigger Line produces the final output for the user:

  • LONG Signal: Occurs when the Trigger Line moves below the ErgoCCI line, suggesting upward momentum.
  • SHORT Signal: Occurs when the Trigger Line moves above the ErgoCCI line, suggesting downward momentum.
  • NEUTRAL Signal: Occurs when both lines are equal, indicating a period of equilibrium or indecision in the market.

In summary, this script filters out minor price fluctuations to provide a clearer picture of market direction, using a "momentum-over-magnitude" ratio to help traders identify where the trend is heading.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
17 Views
0 Downloads
0 Favorites
FXSnipersErgodic_CCITrigger
//+------------------------------------------------------------------+
//|                                       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=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