SSL_channel_chart_alert_mtf





//+------------------------------------------------------------------+
//|                                            SSL channel chart.mq4 |
//|                                                           mladen |
//|                                                                  |
//| initial SSL for metatrader developed by Kalenzo                  |
//+------------------------------------------------------------------+
//mtf2008fxtsd

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

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Green
#property indicator_width1 2
#property indicator_width2 2

//
//
//
//
//

extern int  Lb            = 10;
extern int  sslMA_method  = 0;   //default SMA

extern bool alertsOn             = true;
extern bool alertsMessageBox     = true;
extern bool alertsSound          = false;
extern string alertsSoundFile    = "alert2.wav";  //enterSoundFile
extern bool alertsEmail          = false;
extern bool alertsAfterBarClose  = true;

extern int     TimeFrame    =  0;
extern string  TimeFrames   = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
extern string  MA_method_   = "SMA0 EMA1 SMMA2 LWMA3";

double ssld[];
double sslu[];
double Hlv[];

string IndicatorFileName;

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

int init()
{
   IndicatorBuffers(3);
   SetIndexBuffer(0,ssld); SetIndexDrawBegin(0,Lb+1);
   SetIndexBuffer(1,sslu); SetIndexDrawBegin(0,Lb+1);
   SetIndexBuffer(2,Hlv);

   TimeFrame=MathMax(TimeFrame,Period());
   IndicatorFileName = WindowExpertName();

   return(0);
}

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

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;

   if (TimeFrame != Period())
   {
      datetime TimeArray[];
         limit = MathMax(limit,TimeFrame/Period());
         ArrayCopySeries(TimeArray, MODE_TIME, NULL,TimeFrame);


         for(i=0,int y=0; i<limit; i++)
         {
            if(Time[i]<TimeArray[y]) y++;
         
         ssld[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Lb,sslMA_method,alertsOn,alertsMessageBox,
                                          alertsSound,alertsSoundFile,alertsEmail,alertsAfterBarClose,0,y);
         sslu[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Lb,sslMA_method,alertsOn,alertsMessageBox,
                                          alertsSound,alertsSoundFile,alertsEmail,alertsAfterBarClose,1,y);

         }
   
         
      return(0);         
   }

   //
   //
   //
   //
   //

   for(i=limit;i>=0;i--)
   {
      Hlv[i] = Hlv[i+1];
         if(Close[i]>iMA(Symbol(),0,Lb,0,sslMA_method,PRICE_HIGH,i+1)) Hlv[i] =  1;
         if(Close[i]<iMA(Symbol(),0,Lb,0,sslMA_method,PRICE_LOW,i+1))  Hlv[i] = -1;
      
         if(Hlv[i] == -1)
            {
               ssld[i] = iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1);
               sslu[i] = iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW ,i+1);
            }               
         else
            {
               ssld[i] = iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_LOW ,i+1);
               sslu[i] = iMA(Symbol(),0,Lb,0,MODE_SMA,PRICE_HIGH,i+1);
            } 
   }
   
   //
   //
   //
   //
   //
   
   if (alertsOn)
   {

      int alertFirstBar  =0;
      int alertSecondBar =1;
         
         
         if (alertsAfterBarClose)
         {
         alertFirstBar  = 1;
         alertSecondBar = 2;                  
         }                  

      
      if (Hlv[alertFirstBar] != Hlv[alertSecondBar])
      if (Hlv[alertFirstBar] == 1)
 
            doAlert("Up");
      else  doAlert("Down");    
   
   }     
   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",TimeFrame," at ",Close[0]," SSL trend changes to ",doWhat);
             if (alertsMessageBox) Alert(message);
             if (alertsEmail)   SendMail(StringConcatenate(Symbol(),"SSL "),message);
             if (alertsSound)   PlaySound(alertsSoundFile);
      }
}

//----



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar
Series array that contains close prices for each bar


Indicator Curves created:



Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features:

It issuies visual alerts to the screen
It sends emails
It plays sound alerts