FXSErgoCCITrig[L]

Download script
FXSErgoCCITrig[L]

This tool is a specialized technical analysis indicator designed to help traders identify momentum shifts and potential entry points in the financial markets. Rather than looking at price movements in isolation, it analyzes the underlying "energy" or volatility of the market to distinguish between meaningful trends and minor fluctuations.

Core Logic and Methodology

The script operates by breaking down market data into several layers of processing:

1. Measuring Momentum (Movement) The first step is calculating the raw change between consecutive closing prices. This identifies the direction and speed at which the price is moving. The tool also captures the "absolute" value of these movements—essentially measuring how much the price is moving, regardless of whether that movement is up or down.

2. Smoothing the Data To filter out the "noise" of erratic price spikes, the script applies multiple layers of moving averages to both the direction and the intensity of the price movement. By layering these averages, the indicator smooths out short-term volatility, allowing the user to see the broader trend more clearly.

3. The Ergodic Calculation The core of the tool is a specific calculation that compares different smoothed layers of momentum against one another. It essentially looks at the relationship between recent price activity and historical averages. This produces two distinct visual lines on your chart:

  • Ergodic CCI: Represents the primary calculated momentum line.
  • Trigger Line: A secondary, smoothed version of the Ergodic CCI that acts as a signal threshold.

How to Interpret the Results

The indicator provides real-time feedback by comparing these two lines against each other. The relationship between them generates three specific states:

  • LONG Signal: Occurs when the Trigger Line falls below the Ergodic CCI line, suggesting upward momentum is strengthening.
  • SHORT Signal: Occurs when the Trigger Line rises above the Ergodic CCI line, suggesting downward momentum is gaining strength.
  • NEUTRAL State: Occurs when both lines are equal, indicating a period of equilibrium or indecision in the market.

Customization Options

The tool is highly flexible and allows users to adjust how "sensitive" the indicator is. You can change the type of moving average used (Simple, Exponential, Smoothed, or Linear Weighted) and adjust various parameters that determine how many past bars of data are taken into account for each layer of calculation. This allows the tool to be tailored to different timeframes or trading styles, from fast-paced scalping to slower, more stable trend following.

11 Views
0 Downloads
0 Favorites
FXSErgoCCITrig[L]
//+------------------------------------------------------------------+
//|  FXSniperErgodicCCITrigger[L]         Louw Coetzer aka FX Sniper |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//|                                          rejuvenated by Linuxser |
//+------------------------------------------------------------------+
#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    DarkGoldenrod 
#property indicator_width1    2
#property indicator_color2    MediumVioletRed
#property indicator_width2    1 

// Ergo Variables

extern int pq =2;
extern int pr = 10;
extern int ps = 5;
extern int trigger =3;
extern int ModeMA =2;
extern string    MaMode = "ModeMa(SMA0,EMA1,SmmMA2,LWMA3";

extern int MaxBars=500;
//MODE_SMA    0 Simple moving average, 
//MODE_EMA    1 Exponential moving average, 
//MODE_SMMA   2 Smoothed moving average, 
//MODE_LWMA   3 Linear weighted moving average. 

//---- indicator buffers

string signal;
string MA;
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);
   SetIndexStyle(1,DRAW_LINE);
   
   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;
   
   SetIndexDrawBegin(0,Bars-MaxBars);
   SetIndexDrawBegin(1,Bars-MaxBars);
 
//---- 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,ModeMA,i);
   }
   for(i=0; i <= Bars-1; i++) 
   {
   var2[i]= iMAOnArray(var1,Bars,pr,0,ModeMA,i);
   }
   for(i=0; i <= Bars-1; i++) 
   {
   var2a[i]= iMAOnArray(absmtm,0,pq,0,ModeMA,i);
   }
   for(i=0; i <= Bars-1; i++) 
   {
   var2b[i]= iMAOnArray(var2a,0,pr,0,ModeMA,i);
   }
    for(i=0; i <= Bars-1; i++) 
   {   
   if(iMAOnArray(var2,0,ps,0,ModeMA,i) != 0)
   ErgoCCI[i] = (500 * iMAOnArray(var2,0,ps,0,ModeMA,i))/(iMAOnArray(var2b,0,ps,0,ModeMA,i)); //var2a[i]/var2b[i];
   
   }
   for(i=0; i<=Bars; i++)
   {
     MainCCI[i]=iMAOnArray(ErgoCCI,0,trigger,0,ModeMA,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";}
      if (ModeMA == 0)
      {MA = "SMA";}
      if (ModeMA == 1)
      {MA = "EMA";} 
      if (ModeMA == 2)
      {MA = "SMMA";} 
      if (ModeMA == 3)
      {MA = "LWMA";}  
 
    IndicatorShortName("FXSErgoCCI,("+MA+","+pq+","+pr+","+ps+","+trigger+"),["+signal+"]");
   return(0); }
  }
//+------------------------------------------------------------------+

Comments