ma_2xMAcross_alert_satop





//+------------------------------------------------------------------+
//|                                                         2xMA.mq4 |
//|                                                     Yuriy Tokman |
//|                                            yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman"
#property link      "yuriytokman@gmail.com"

#property indicator_chart_window

#property indicator_buffers 4
#property indicator_color1 Yellow
#property indicator_color2 Red
#property indicator_color3 Yellow
#property indicator_color4 Red

extern bool tired_from_noise = true;

extern string __1__        = "Fast MA";
extern int PeriodMA_1      = 5;
extern int ma_method_1     = 1;//0-3
extern int applied_price_1 = 6;//0-6

extern string __2__        = "Slow MA";
extern int PeriodMA_2      = 12;
extern int ma_method_2     = 1;//0-3
extern int applied_price_2 = 6;//0-6

extern string __3__ = "Another";
extern int shift           = 0;
extern int arrow_code_up   = 218;
extern int arrow_code_down = 217;
extern int width           = 3;


double ExtMapBuffer0[];
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];

datetime LastTime=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer0);
   
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer1);
   
   SetIndexStyle(2,DRAW_ARROW,EMPTY,width);
   SetIndexArrow(2,arrow_code_up);
   SetIndexBuffer(2,ExtMapBuffer2);
   SetIndexEmptyValue(2,0.0);
   
   SetIndexStyle(3,DRAW_ARROW,EMPTY,width);
   SetIndexArrow(3,arrow_code_down);
   SetIndexBuffer(3,ExtMapBuffer3);
   SetIndexEmptyValue(3,0.0);
   
   IndicatorShortName("2xMA ("+PeriodMA_1+")");
   
   SetIndexLabel(0," ISQ#481971287  ");
   SetIndexLabel(1," yuriytokman@gmail.com  ");
   SetIndexLabel(2," ISQ#481971287  ");
   SetIndexLabel(3," yuriytokman@gmail.com  ");   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
//----
   int limit;
   int counted_bars=IndicatorCounted();
   
   if(counted_bars<0) return(-1);

   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(int i=limit; i>=0; i--)
   {
     double MA_1_0    = iMA(NULL,0,PeriodMA_1,0,ma_method_1,applied_price_1,i+shift);
     double MA_1_1    = iMA(NULL,0,PeriodMA_1,0,ma_method_1,applied_price_1,i+shift+1);
     double MA_2_0    = iMA(NULL,0,PeriodMA_2,0,ma_method_2,applied_price_2,i+shift);
     double MA_2_1    = iMA(NULL,0,PeriodMA_2,0,ma_method_2,applied_price_2,i+shift+1);
     ExtMapBuffer0[i] = MA_1_0;
     ExtMapBuffer1[i] = MA_2_0;
     
     if (MA_1_1>=MA_2_1 && MA_1_0<MA_2_0 && Time[i]!= LastTime)
      {
       ExtMapBuffer2[i]=High[i]+5*Point;
       LastTime = Time[i];
       if(!tired_from_noise)Alert("Downwards "," Period:",Period()," TimeFrame:",GetNameTF());
      }
     
     if (MA_1_1<=MA_2_1 && MA_1_0>MA_2_0 && Time[i]!= LastTime)
      {
       ExtMapBuffer3[i]=Low[i]-5*Point;
       LastTime = Time[i];
       if(!tired_from_noise)Alert("Upwards "," Period:",Period()," TimeFrame:",GetNameTF());
      }        
   }
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//+----------------------------------------------------------------------------+
//|  ?????    : ??? ????? ?. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  ??????   : 01.09.2005                                                     |
//|  ???????? : ?????????? ???????????? ??????????                             |
//+----------------------------------------------------------------------------+
//|  ?????????:                                                                |
//|    TimeFrame - ????????? (?????????? ??????)      (0 - ??????? ??)         |
//+----------------------------------------------------------------------------+
string GetNameTF(int TimeFrame=0) {
  if (TimeFrame==0) TimeFrame=Period();
  switch (TimeFrame) {
    case PERIOD_M1:  return("M1");
    case PERIOD_M5:  return("M5");
    case PERIOD_M15: return("M15");
    case PERIOD_M30: return("M30");
    case PERIOD_H1:  return("H1");
    case PERIOD_H4:  return("H4");
    case PERIOD_D1:  return("Daily");
    case PERIOD_W1:  return("Weekly");
    case PERIOD_MN1: return("Monthly");
    default:         return("UnknownPeriod");
  }
}



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar
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

Implements a curve of type DRAW_ARROW

Indicators Used:

Moving average indicator


Custom Indicators Used:

Order Management characteristics:

Other Features:

It issuies visual alerts to the screen