//+------------------------------------------------------------------+
//|                                                 4_Mashki_ind.mq4 |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 C'177,252,177'
#property indicator_width1 17
#property indicator_color2 C'233,218,233'
#property indicator_width2 17
#property indicator_color3 Chocolate
#property indicator_width3 2
#property indicator_color4 Chocolate
#property indicator_width4 1
#property indicator_style4 1
#property indicator_color5 Magenta
#property indicator_width5 2
extern int ma_1 = 3;
extern int ma_2 = 34;
extern int method_1 = 1;
extern int price_1 = 0;
extern int ma_shift_1 = 0;
extern int method_2 = 1;
extern int price_2 = 0;
extern int ma_shift_2 = 0;
extern bool ShowSignal=false;
extern bool ВсегдаПоказыватьМА=false;
extern int ma_width = 0;

int key;
double ExtMapBuffer1[], ExtMapBuffer2[], ExtMapBuffer3[], ExtMapBuffer4[], ExtMapBuffer5[];
int ExtCountedBars=0, skey;
//+------------------------------------------------------------------+
int init()  {
   if(ma_2!=34) skey=1;
   SetIndexStyle(0,DRAW_HISTOGRAM, EMPTY, ma_width);   SetIndexBuffer(0,ExtMapBuffer1);   SetIndexDrawBegin(0,10);
   SetIndexStyle(1,DRAW_HISTOGRAM, EMPTY, ma_width);   SetIndexBuffer(1,ExtMapBuffer2);   SetIndexDrawBegin(1,10);
   SetIndexStyle(2,DRAW_LINE);        SetIndexBuffer(2,ExtMapBuffer3);   SetIndexDrawBegin(2,10);
   SetIndexStyle(3,DRAW_LINE);        SetIndexBuffer(3,ExtMapBuffer4);   SetIndexDrawBegin(3,10);
   if((_Period==1 || ВсегдаПоказыватьМА)  && skey==0)  {  SetIndexStyle(4,DRAW_LINE);        SetIndexBuffer(4,ExtMapBuffer5);   SetIndexDrawBegin(4,10);  }
   return(0);
  }
//+------------------------------------------------------------------+
int start()  {
   if(Bars<=10) return(0);
   ExtCountedBars=IndicatorCounted();
   if (ExtCountedBars<0) return(-1);
   if (ExtCountedBars>0) ExtCountedBars--;
   int pos=Bars-ExtCountedBars-1;
   while(pos>=0)   { 
      ExtMapBuffer1[pos]=iMA(Symbol(),0,ma_1,ma_shift_1,method_1,price_1,pos);
      ExtMapBuffer2[pos]=iMA(Symbol(),0,ma_2,ma_shift_2,method_2,price_2,pos);
      ExtMapBuffer3[pos]=iMA(Symbol(),0,ma_2,ma_shift_2,method_2,price_2,pos);
      if(_Period<15)  ExtMapBuffer4[pos]=iMA(Symbol(),0,ma_2*15/_Period,0,1,0,pos);
      if(_Period==1 || ВсегдаПоказыватьМА)  ExtMapBuffer5[pos]=iMA(Symbol(),0,34,16,2,0,pos);
 	   pos--;
   }
   if(key!=Time[0] && ShowSignal)  {
     if(High[1]>ExtMapBuffer2[1] && Low[1]<ExtMapBuffer2[1])  Alert(Symbol(),"   ", Period(), " Пересечение границы Buy-Sell");
     key=Time[0];
   }
   return(0);
}
//+------------------------------------------------------------------+

