Trix_4c_alert_mtf

Author: mladen
Trix_4c_alert_mtf

This script is a sophisticated technical analysis tool designed to identify momentum shifts and potential price reversals in the financial markets. It utilizes a multi-layered calculation method that combines smoothing techniques with specialized mathematical transforms to filter out market "noise" and highlight significant trends.

Core Logic and Processing

The indicator functions by taking raw price data and passing it through several sequential stages of processing:

  • Layered Smoothing: The script begins by applying multiple moving averages to the price. Instead of just looking at the current price, it analyzes a series of nested averages (a "Trix" style calculation), which helps in identifying the underlying direction of the market while removing minor fluctuations.
  • Momentum Extraction: Once smoothed, the script calculates the rate of change between these layers. By measuring how quickly the values are moving relative to one another, it creates a momentum profile.
  • Ergodic & Signal Processing: The logic further refines this momentum by applying additional smoothing cycles (referred to as Ergodic CCI elements). This results in two primary visual signals: a "Main" line and an "Ergodic" signal line.

Visual Indicators and Dynamics

The tool populates the chart with several distinct visual components:

  • Histogram Elements: The script generates a series of histograms that represent different stages of the calculation. These provide a visual representation of current momentum strength.
  • Directional Logic: The histogram colors and shapes change based on whether the momentum is increasing or decreasing, as well as whether it is currently above or below the zero line (indicating bullish or bearish territory).

Alerts and Signal Generation

The primary purpose of this script is to provide real-time notifications for specific "crosses." It monitors the relationship between the Main momentum line and the Ergodic signal line:

  • Long Signals: An alert is triggered when the Main line crosses from below to above the Signal line, suggesting a potential upward move.
  • Short Signals: An alert is triggered when the Main line crosses from above to below the Signal line, suggesting a potential downward move.

Multi-Timeframe Capabilities

One of the professional features of this script is its ability to handle "Multi-Timeframe" analysis. It can be configured to calculate and display data from different time periods (e.g., viewing hourly trends on a minute chart) simultaneously, ensuring that the user is aware of broader market trends while looking at immediate price action.

User Interaction

The script is equipped with a comprehensive alert system. Depending on your preferences, it can notify you via:

  • Audible Alerts: Playing a sound file to grab your attention.
  • Pop-up Messages: Displaying a text notification directly on the trading platform.
  • Email Notifications: Sending an automated message to your registered email address when a trend crossover occurs.
Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1It plays sound alertsIt issuies visual alerts to the screenIt sends emails
10 Views
0 Downloads
0 Favorites
Trix_4c_alert_mtf
//+------------------------------------------------------------------+
//| FX_Sniper's_Ergodic_CCI_&_Trigger_Alert_Fast      by      mladen |
//+------------------------------------------------------------------+
//2008fxtsd

//mod 2009fxtsd Trix_4c_alert_mtf.mq4



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



#property  indicator_separate_window
#property  indicator_buffers 6
#property  indicator_color1  Red
#property  indicator_color2  Green
#property  indicator_color3  Red
#property  indicator_color4  Green
#property  indicator_color5  DarkOrange
#property  indicator_color6  Blue

#property  indicator_width3 2
#property  indicator_width4 2
#property  indicator_width5 2
#property  indicator_width6 2

//
//
//
//
//
extern int    Trixperiod      = 5;
extern int    sigMAperiod     = 7;
extern int    priorsmzper     = 3;
extern int    smzperiod       = 3;
extern int    MAmethod        = 1;
extern int    price           = 5;


extern int TimeFrame = 0;


extern bool alertsOn      = true;
extern bool alertsSound   = true;
extern bool alertsMessage = true;
extern bool alertsEmail   = false;
extern double osmaMult = 2;

extern string  note_timeframes  = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
extern string  ma_method_price = "SMA0 EMA1 SMMA2 LWMA3||0O,1C 2H3L,4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";

string IndicatorFileName;

double ErgoCCI[];
double MainCCI[];

double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];
double buffer5[];
double buffer6[];


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

int init()
{
   IndicatorBuffers(8);

   SetIndexBuffer(0,buffer1);
   SetIndexBuffer(1,buffer4);
   SetIndexBuffer(2,buffer3);
   SetIndexBuffer(3,buffer2);

   SetIndexBuffer(4,MainCCI); SetIndexLabel(4,"Trix");
   SetIndexBuffer(5,ErgoCCI); SetIndexLabel(5,"TrixSigMA");

   SetIndexBuffer(6,buffer5);
   SetIndexBuffer(7,buffer6);
 
 
  SetIndexStyle(0,DRAW_HISTOGRAM);
  SetIndexStyle(1,DRAW_HISTOGRAM);
  SetIndexStyle(2,DRAW_HISTOGRAM);
  SetIndexStyle(3,DRAW_HISTOGRAM);

   TimeFrame=MathMax(TimeFrame, Period());

   string shortname = "Trix ("+Trixperiod+","+sigMAperiod+"; "+priorsmzper+","+smzperiod+"; "+MAmethod+","+price+") M"+TimeFrame+" ";
   IndicatorShortName (shortname);
  
   IndicatorFileName = WindowExpertName();


   return(0);
}


//
//
//
//
//

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]);
            
                  buffer1[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osmaMult,0,y);
                  buffer4[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osmaMult,1,y);
                  buffer3[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osmaMult,2,y);
                  buffer2[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osmaMult,3,y);
                  MainCCI[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osmaMult,4,y);
                  ErgoCCI[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osmaMult,5,y);



          }

         return(0);         
      }
   //
   //
   //
   //
   //


   buffer1[i]=EMPTY_VALUE;   buffer2[i]=EMPTY_VALUE;     buffer3[i]=EMPTY_VALUE;
   buffer4[i]=EMPTY_VALUE;   buffer5[i]=EMPTY_VALUE;     buffer6[i]=EMPTY_VALUE;


   for(i=limit;i>=0;i--)      buffer1[i]= iMA(NULL,0,priorsmzper,0,MAmethod,price,i);

   for(i=limit;i>=0;i--)      buffer2[i]= iMAOnArray(buffer1,0,Trixperiod,0,MAmethod,i);
   for(i=limit;i>=0;i--)      buffer3[i]= iMAOnArray(buffer2,0,Trixperiod,0,MAmethod,i);
   for(i=limit;i>=0;i--)      buffer5[i]= iMAOnArray(buffer3,0,Trixperiod,0,MAmethod,i);

   for(i=limit;i>=0;i--)      buffer4[i]= (buffer5[i]-buffer5[i+1])*1000;
   for(i=limit;i>=0;i--)      MainCCI[i]= iMAOnArray(buffer4,0,smzperiod,0,MAmethod,i);
   for(i=limit;i>=0;i--)      ErgoCCI[i]= iMAOnArray(MainCCI,0,sigMAperiod,0,MAmethod,i);   

   for(i=limit;i>=0;i--)      buffer6[i]=(iMAOnArray(MainCCI,0,smzperiod,0,MAmethod,i)-
                                          iMAOnArray(ErgoCCI,0,smzperiod,0,MAmethod,i))*osmaMult;
//
//
//

   for(i=limit;i>=0;i--) 
   {
                                 buffer1[i]=EMPTY_VALUE;    buffer2[i]=EMPTY_VALUE;
                                 buffer3[i]=EMPTY_VALUE;    buffer4[i]=EMPTY_VALUE;
 
                  
            if  (buffer6[i]>buffer6[i+1]) 
               {
               if (buffer6[i]>0) buffer2[i]=buffer6[i];
               else              buffer3[i]=buffer6[i];
                }
        
            else   
                
               if (buffer6[i]>0) buffer4[i]=buffer6[i];
               else              buffer1[i]=buffer6[i];
               
//
//
//

   if (alertsOn)
      {
       if(MainCCI[i+1] < ErgoCCI[i+1] && MainCCI[i] > ErgoCCI[i]) doAlert("goes long");
       if(MainCCI[i+1] > ErgoCCI[i+1] && MainCCI[i] < ErgoCCI[i]) doAlert("goes short");
      }



    }

   return(0);
  }


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

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

          //
          //
          //
          //
          //

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

Comments