iMAXalert2





/*+-------------------------------------------------------------------+
  |                                                     iMAXalert.mq4 |
  |                                                                   |
  | "Modified Optimum Elliptic Filter"                                |
  | Source of calculations:                                           |
  | Stocks & Commodities vol 18:7 p20-29                              |
  | Optimal Detrending by John F. Ehlers                              |
  |                                                                   |
  |                                                  Crafted by Wylie |
  |                                              dazzle.html@live.com |
  +-------------------------------------------------------------------+*/

#property copyright "Wylie"
#property link      "dazzle.html@live.com"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 Red
#property indicator_width1 1
#property indicator_width2 1

/*+-------------------------------------------------------------------+
  | iMAXalert Parameters                                              |
  +-------------------------------------------------------------------+*/

extern int      Ph2shiftRed   = 1;
extern bool     EnableAlerts  = true;
extern string   a_            = "Stop Alerts from sounding more than";
extern string   b_            = "once every ? seconds (+ 1 tick time).";
extern int      AlertStopTime = 20;

int    buffers = 2,
       Threshold,            // Pips above crossing up, or pips below crossing down.
                             // Change the values in the init() function if you need to.
       MinBars,c;

double ExtMapBuffer0[],
       ExtMapBuffer1[];

string Chart;

static datetime AlertX[2];

/*+-------------------------------------------------------------------+
  | iMAXalert Initialization                                          |
  +-------------------------------------------------------------------+*/

int init()
{
 IndicatorBuffers(2);

 // Index Buffer 0

 SetIndexBuffer(0,ExtMapBuffer0);
 SetIndexShift(0,0);
 SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,Aqua);

 // Index Buffer 1

 SetIndexBuffer(1,ExtMapBuffer1);
 SetIndexShift(1,0);
 SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,Red);

 IndicatorShortName("iMAX");
 MinBars = 20;

 switch(Period())
     {case 1: Chart = "M1";  Threshold =  1;break;
      case 2: Chart = "M5";  Threshold =  1;break;
      case 3: Chart = "M15"; Threshold =  2;break;
      case 4: Chart = "M30"; Threshold =  2;break;
      case 5: Chart = "H1";  Threshold =  5;break;
      case 6: Chart = "H4";  Threshold = 10;break;
      case 7: Chart = "D1";  Threshold = 10;break;
      case 8: Chart = "W5";  Threshold = 30;break;
      case 9: Chart = "MN";  Threshold = 30;break;}

 return (0);
} // int init()
  
/*+-------------------------------------------------------------------+
  | iMAXalert Main cycle                                              |
  +-------------------------------------------------------------------+*/

int start()
{    
 if(Bars <= MinBars){return (0);}

double b0 = ExtMapBuffer0[0],
       b1 = ExtMapBuffer0[1],
       r0 = ExtMapBuffer1[0],
       r1 = ExtMapBuffer1[1];

 int countedBars = IndicatorCounted();

 if(countedBars < 0){return (-1);}
 if(countedBars > 0){countedBars--;}

 int c,limit = Bars - countedBars - 1;
 double x = 0.5;

 for(c = limit;c >= 0;c--)
     {ExtMapBuffer0[c] = (0.13785 * (2 * ((High[c]   + Low[c])   * x) - ((High[c+1] + Low[c+1]) * x)))
                       + (0.0007  * (2 * ((High[c+1] + Low[c+1]) * x) - ((High[c+2] + Low[c+2]) * x)))
                       + (0.13785 * (2 * ((High[c+2] + Low[c+2]) * x) - ((High[c+3] + Low[c+3]) * x)))
                       + (1.2103  * ExtMapBuffer0[c + 1] - 0.4867 * ExtMapBuffer0[c + 2]); 

      ExtMapBuffer1[c] = ExtMapBuffer0[c+Ph2shiftRed];
     } // for(c = limit;c >= 0;c--)

 if(EnableAlerts)
    {if(b0 > r0 + (Threshold * Point) && b1 < r1 + (Threshold * Point))
        {sendAlert(0,(getDateTime()+" "+Symbol()+" "+Chart+" iMAX signals up trend crossing."));}
     if(b0 < r0 - (Threshold * Point) && b1 > r1 - (Threshold * Point))
        {sendAlert(1,(getDateTime()+" "+Symbol()+" "+Chart+" iMAX signals down trend crossing."));}}

 return (0);  
} // int start()

/*+-------------------------------------------------------------------+
  | End iMAXalert Main cycle                                          |
  +-------------------------------------------------------------------+*/



/*+-------------------------------------------------------------------+
  | iMAXalert support functions                                       |
  +-------------------------------------------------------------------+*/

/*+-------------------------------------------------------------------+
  | *** Alert processing function                                     |
  +-------------------------------------------------------------------+*/

void sendAlert(int AlertNum,string AlertText)
{
 if(TimeCurrent() > AlertX[AlertNum] + AlertStopTime)
    {AlertX[AlertNum] = TimeCurrent();
                                        /* Add a sound file here if you want another form of alert...
                                           The sound file must be located in the MT4 "sounds" file folder 
                                           and must be a .wav format file. */
//     PlaySound("alert.wav"); 
     Alert(AlertText);}

 return(0);
} // 

/*+-------------------------------------------------------------------+
  | *** Date/Time display function                                    |
  +-------------------------------------------------------------------+*/

string getDateTime()
{
 string dsplyDateTime = TimeToStr(TimeCurrent(),TIME_DATE|TIME_DATE)+" "+
                        TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS);
 return(dsplyDateTime);

} // datetime getTime()

/*+-------------------------------------------------------------------+
  | End iMAXalert support functions                                   |
  +-------------------------------------------------------------------+*/






Sample





Analysis



Market Information Used:

Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:


Implements a curve of type DRAW_LINE

Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features:

It issuies visual alerts to the screen