FX_Sniper's_Ergodic_CCI_Trigger_001

Download script
FX_Sniper's_Ergodic_CCI_Trigger_001

This trading indicator, titled the "FX Sniper," is designed to help traders identify momentum shifts and potential entry points by analyzing price fluctuations through a multi-layered mathematical process. Instead of looking at raw price movements directly, it processes data through several stages of smoothing and averaging to filter out market "noise" and highlight significant trends.

How the Logic Works

The script operates by breaking down market movement into three primary components:

1. Movement Analysis (Momentum) First, the tool calculates the basic change between consecutive closing prices. It then takes these changes and converts them into their absolute values (essentially measuring the "strength" of the move regardless of whether the price went up or down).

2. Multi-Layered Smoothing To ensure the signals are not triggered by tiny, insignificant price flickers, the script applies several layers of Exponential Moving Averages (EMA). It smooths the raw momentum data multiple times. By doing this, the tool creates a "weighted" view of the market where recent trends carry significant importance while older, less relevant data is gradually phased out.

3. The Ergodic CCI Calculation The core of this indicator is the "Ergodic CCI." This is derived by comparing the smoothed momentum of the price movements against the smoothed strength of the absolute moves. By dividing these two specific averages, the script creates a specialized ratio that represents the current market state.

Visual Signals and Alerts

The indicator produces two primary visual lines on your chart:

  • Ergodic CCI: This represents the primary momentum flow.
  • Trigger Line: A secondary line that acts as a "confirmation" filter, smoothed over a specific timeframe.

The Trading Logic: The script constantly compares the position of the Trigger Line against the Ergodic CCI. It interprets their relationship to generate three distinct states:

  • Long Signal: Triggered when the Trigger Line falls below the Ergodic CCI. This suggests a downward momentum shift.
  • Short Signal: Triggered when the Trigger Line rises above the Ergodic CCI. This suggests an upward momentum shift.
  • Neutral: Occurs when the two lines are equal, indicating a period of equilibrium where no clear trend is established.

Automated Notifications The script includes an automated alert system. When the logic detects a switch from one state to another (for example, moving from Neutral to Short), it generates a real-time pop-up alert on your platform. It is programmed with "intelligence" to ensure you aren't bombarded with repetitive alerts; it will only notify you once per price candle when a new signal actually occurs.

Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
9 Views
0 Downloads
0 Favorites
FX_Sniper's_Ergodic_CCI_Trigger_001
//+------------------------------------------------------------------+
//|                                       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;
double alertTag;

//---- indicator buffers

string signal;
string lastsignal;
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,"Ergodic 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(lastsignal != signal && alertTag!=Time[0]){
    Alert("Sniper going Short on ",Symbol()," i= ",i);
    alertTag = Time[0];
    lastsignal=signal;
     }
     }
      if (MainCCI[i] < ErgoCCI[i]){
      {signal = "LONG";}
    if(lastsignal != signal && alertTag!=Time[0]){
    Alert("Sniper going LONG on ",Symbol()," i= ",i);
    alertTag = Time[0];
    lastsignal=signal;
     }}
      if (MainCCI[i] == ErgoCCI[i])
      {signal = "NEUTRAL";}
 
    IndicatorShortName("FX Sniper's Ergodic CCI & Trigger: "+signal);
   return(0); }
  }
//+------------------------------------------------------------------+

Comments