MTF_Supertrend_2TFx2LX_Alert





//+------------------------------------------------------------------+
//|  MTF_Supertrend_2LX_Alert             #MTF Supertrend line.mq4 ik|
//|  Increase, forexTSD.com              Copyright © 2006, Eli hayun |
//|                                          http://www.elihayun.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Eli hayun"
#property link      "http://www.elihayun.com"

#property indicator_chart_window
#property indicator_buffers 4
//#property indicator_color1 Bisque
//#property indicator_color2 LightSkyBlue
//#property indicator_color3 PeachPuff
//#property indicator_color4 PaleTurquoise
#property indicator_color1 Magenta
#property indicator_color2 Aqua
#property indicator_color3 MediumPurple
#property indicator_color4 LightCyan
#property indicator_width1 4
#property indicator_width2 4
#property indicator_width3 3
#property indicator_width4 3
//---- buffers

double buf_up1H[];
double buf_down1H[];

double buf_up30M[];
double buf_down30M[];

extern int Period_1 = 60;
extern int Period_2 = 240;

extern bool AutoDisplay      = true;

extern bool display_Period_1 = true;
extern bool display_Period_2 = true;

extern bool AlertMode = true;
extern bool Play_Sound = false;
extern bool additional = false;
double alertTag;
double previous;
double last;
double test1;
double test2;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators

   int draw = DRAW_LINE; 
   
   draw = DRAW_LINE; if (!display_Period_2) draw = DRAW_NONE;
   SetIndexStyle(0,draw);
   SetIndexBuffer(0,buf_up1H);
   SetIndexStyle(1,draw);
   SetIndexBuffer(1,buf_down1H);

   draw = DRAW_LINE; if (!display_Period_1) draw = DRAW_NONE;
   SetIndexStyle(2,draw);
   SetIndexBuffer(2,buf_up30M);
   SetIndexStyle(3,draw);
   SetIndexBuffer(3,buf_down30M);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int i=0,limit, y1d=0, y4h=0, y1h=0, y30m=0;
   limit=Bars-counted_bars +Period_1/Period();
   limit=Bars-counted_bars+Period_2/Period();

   datetime TimeArray_1D[] ,TimeArray_4H[], TimeArray_1H[], TimeArray_30M[];
//----
 
   ArrayCopySeries(TimeArray_1H,MODE_TIME,Symbol(),Period_2); 
   ArrayCopySeries(TimeArray_30M,MODE_TIME,Symbol(),Period_1);
      
   for(i=0, y1d=0,  y4h=0,  y1h=0,  y30m=0;i<limit;i++)
   {
      if (Time[i]<TimeArray_1H[y1h]) y1h++;
      if (Time[i]<TimeArray_30M[y30m]) y30m++;
 
      buf_up1H[i] = iCustom(NULL, Period_2, "SuperTrendLX", false, 1, y1h);
      test1 = iCustom(NULL, Period_2, "SuperTrendLX", false, 1, y1h);
      buf_down1H[i] = iCustom(NULL, Period_2, "SuperTrendLX", false, 0, y1h);
      test2 = iCustom(NULL, Period_2, "SuperTrendLX", false, 0, y1h);
      
      buf_up30M[i] = iCustom(NULL, Period_1, "SuperTrendLX", false, 1, y30m);
      test1 = iCustom(NULL, Period_1, "SuperTrendLX", false, 1, y30m);
      buf_down30M[i] = iCustom(NULL, Period_1, "SuperTrendLX", false, 0, y30m);
     test2 = iCustom(NULL, Period_1, "SuperTrendLX", false, 0, y30m);
 if(AlertMode){
  if(previous==0) previous = test1;
  if(last==0) last = previous;
 if( test1 == test2 && previous > test1 && alertTag!=Time[0]) {
   Alert("Supertrend change direction Up on ",Symbol()," ",Period());
     alertTag = Time[0];
     previous=test1;
    }
 if( test1 == test2 && previous < test1 && alertTag!=Time[0]){
   Alert("Supertrend change direction down on ",Symbol()," ",Period());
     alertTag = Time[0];
     previous=test1;
    }
   }}
   return(0);
  }
//+------------------------------------------------------------------+






Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:

Implements a curve of type draw


Indicators Used:




Custom Indicators Used:
SuperTrendLX

Order Management characteristics:

Other Features:

It issuies visual alerts to the screen