FXSnipers_ErgodicCCI_SW_Arrow

Download script
Author: mladen
FXSnipers_ErgodicCCI_SW_Arrow

This script is a specialized technical analysis tool designed for the MetaTrader platform. Its primary purpose is to identify specific momentum shifts in financial markets by calculating and visualizing two distinct data streams: the Ergodic CCI and a Trigger Line.

Core Logic Overview

The script operates by analyzing price fluctuations over time to determine the "velocity" of the market. Rather than just looking at where the price is, it looks at how fast and in what direction the price is moving, smoothing out minor "noise" to highlight significant trends.

Key Components of the Analysis:

  • Ergodic CCI (The Momentum Signal): This is the primary calculation. It processes the difference between consecutive closing prices. By applying a multi-layered smoothing technique (using specific user-defined parameters like pq, pr, and ps), it creates a refined momentum indicator. It essentially measures how much "force" is behind the current price move compared to its recent history.
  • The Trigger Line: This acts as a dynamic baseline. Instead of staying static, the Trigger Line reacts to the Ergodic CCI. It follows the momentum signal but with a slight delay or "weighted" smoothing (controlled by the trigger parameter). This prevents the indicator from giving false signals during tiny, insignificant price wiggles.
  • Cross-over Detection: The primary logic for generating signals is based on the interaction between these two lines:
    • Long Signal: Occurs when the momentum (Ergodic CCI) crosses above the Trigger Line, suggesting upward strength.
    • Short Signal: Occurs when the momentum (Ergodic CCI) crosses below the Trigger Line, suggesting downward pressure.

Visual and Notification Features:

The script is designed to be highly interactive for the user through several automated features:

  • Visual Cues: If enabled, the script places specific icons (arrows) on the chart at the exact moment a crossover occurs, making it easy for a trader to spot entry points visually.
  • Multi-Timeframe Compatibility: The logic is capable of pulling data from different timeframes. This means a trader can look at a 1-minute chart but still see signals based on 15-minute or 1-hour price actions, providing a broader context for the trade.
  • Real-time Alerts: To ensure traders don't have to stare at the screen constantly, the script includes an automated notification system. When a "Long" or "Short" crossover is detected, it can trigger three different types of alerts simultaneously:
    1. Audio: Plays a sound file through the computer's speakers.
    2. Pop-up Alert: Displays a visual message box on the trading platform screen.
    3. Email: Sends a direct notification to a registered email address (if configured).

Summary for the User

In essence, this tool acts as an "early warning system." It filters out the chaotic movements of the market to identify when momentum is shifting from one direction to another, notifying the user immediately via sound, visuals, or messages whenever a significant trend change is detected.

Miscellaneous
It plays sound alertsIt issuies visual alerts to the screenIt sends emails
10 Views
0 Downloads
0 Favorites
FXSnipers_ErgodicCCI_SW_Arrow
//+------------------------------------------------------------------+
//|                                       Louw Coetzer aka FX Sniper |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//| FX_Sniper's_Ergodic_CCI_Trigger_Alert_Mod.mq4
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, Fx Sniper."
#property  link      "http://www.dunno.net/"

//+------------------------------------------------------------------+
//| FX_Sniper's_Ergodic_CCI_&_Trigger_Alert_Fast      by      mladen |
//+------------------------------------------------------------------+
//2008fxtsd

#property copyright "mladen"
#property link      "mladenfx@gmail.com"



#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  Blue
#property  indicator_color2  Red
#property  indicator_width1  2
#property indicator_maximum 2
#property indicator_minimum 0
//
//
//
//
//

extern int  pq            =  1;
extern int  pr            =  7;
extern int  ps            =  3;
extern int  trigger       =  3;

extern int TimeFrame = 0;

extern bool    ShowArrow         = true;
extern double  IndicatorValue    = 1;
extern bool    alertsOn          = true;
extern bool    alertsSound       = true;
extern bool    alertsMessage     = true;
extern bool    alertsEmail       = false;

extern string  note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
string IndicatorFileName;

double ErgoCCI[];
double MainCCI[];
double buffer[][8];


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int init()
{
   SetIndexBuffer(0,ErgoCCI); SetIndexLabel(0,"Ergodic CCI");
   SetIndexBuffer(1,MainCCI); SetIndexLabel(1,"Trigger Line");

if (ShowArrow) 
   {
   SetIndexBuffer(0,ErgoCCI);
   SetIndexStyle  (0,DRAW_ARROW); 
   SetIndexArrow  (0,167);
   SetIndexBuffer(1,MainCCI);
   SetIndexStyle  (1,DRAW_ARROW); 
   SetIndexArrow  (1,167);
   }
   
   TimeFrame=MathMax(TimeFrame, Period());

   string shortname = "FXSniper\'s_Ergodic ("+pq+","+pr+","+ps+"; "+trigger+") ["+TimeFrame+"]";
   IndicatorShortName (shortname);
   IndicatorFileName = WindowExpertName();


   return(0);
}

//
//
//
//
//

#define mtm    0
#define absmtm 1
#define var1   2
#define var2   3
#define var2a  4
#define var2b  5
#define var2c  6
#define var2d  7

//
//
//
//
//

int start()
{
   int i,r,limit,counted_bars=IndicatorCounted();

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;
           
   if (TimeFrame != Period())
      {
         limit = MathMax(limit,TimeFrame/Period());
           
          for(i=limit; i>=0; i--)
          {
            int y = iBarShift(NULL,TimeFrame,Time[i]);
                  ErgoCCI[i] = iCustom(NULL,TimeFrame,IndicatorFileName,pq,pr,ps,trigger,0,alertsOn,alertsSound,alertsMessage, alertsEmail,0,y);
                  MainCCI[i] = iCustom(NULL,TimeFrame,IndicatorFileName,pq,pr,ps,trigger,0,alertsOn,alertsSound,alertsMessage, alertsEmail,1,y);

          }
if (ShowArrow)
   for(int shift =limit; shift>=0; shift--)
   {
       MainCCI[shift] = IndicatorValue; 
       ErgoCCI[shift] = IndicatorValue; 
      
       if (ErgoCCI[shift] > MainCCI[shift])
       {
       MainCCI[shift] = EMPTY_VALUE;
       ErgoCCI[shift] = IndicatorValue;
       }
       else if (ErgoCCI[shift] < MainCCI[shift])
       {
       MainCCI[shift] = IndicatorValue;
       ErgoCCI[shift] = EMPTY_VALUE;
       }
         return(0);         
      }


    if (ArrayRange(buffer,0) != Bars) ArrayResize(buffer,Bars);
 

   //
   //
   //
   //
   //
   

   double alphaPq = 2.0/(1.0+pq);
   double alphaPr = 2.0/(1.0+pr);
   double alphaPs = 2.0/(1.0+ps);
   double alphaTrigger = 2.0/(1.0+trigger);
   
   for(i=limit,r=Bars-limit-1; i >=0; i--,r++) 
   {
      buffer[r][mtm]    = Close[i]-Close[i+1];
      buffer[r][absmtm] = MathAbs(buffer[r][mtm]);
      buffer[r][var1]   = buffer[r-1][var1]  + alphaPq*(buffer[r][mtm]   -buffer[r-1][var1]);
      buffer[r][var2]   = buffer[r-1][var2]  + alphaPr*(buffer[r][var1]  -buffer[r-1][var2]);
      buffer[r][var2a]  = buffer[r-1][var2a] + alphaPq*(buffer[r][absmtm]-buffer[r-1][var2a]);
      buffer[r][var2b]  = buffer[r-1][var2b] + alphaPr*(buffer[r][var2a] -buffer[r-1][var2b]);
      buffer[r][var2c]  = buffer[r-1][var2c] + alphaPs*(buffer[r][var2]  -buffer[r-1][var2c]);
      buffer[r][var2d]  = buffer[r-1][var2d] + alphaPs*(buffer[r][var2b] -buffer[r-1][var2d]);
      if (buffer[r][var2d]!=0)
            ErgoCCI[i] = (500*buffer[r][var2c]/buffer[r][var2d]);
      else  ErgoCCI[i] = 0;
            MainCCI[i] = MainCCI[i+1] + alphaTrigger*(ErgoCCI[i]-MainCCI[i+1]);
      }
   
   }
   if (alertsOn)
      {
       if(MainCCI[1] <= ErgoCCI[1] && MainCCI[0] > ErgoCCI[0]) doAlert("short");
       if(MainCCI[1] >= ErgoCCI[1] && MainCCI[0] < ErgoCCI[0]) doAlert("long");
      }
   return(0);
}


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

void doAlert(string doWhat)
{
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;
   
      if (previousAlert != doWhat || previousTime != Time[0]) {
          previousAlert  = doWhat;
          previousTime   = Time[0];

          //
          //
          //
          //
          //

          message =  StringConcatenate(Symbol()," M",Period()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," ergodic ",doWhat);
             if (alertsSound)   PlaySound("ok.wav");//alert2
             if (alertsMessage) Alert(message);
             if (alertsEmail)   SendMail(StringConcatenate(Symbol()," ergodic crossing"),message);
      }
}

Comments