//+------------------------------------------------------------------+
//|                                            ytg_DveMashki_ind.mq4 |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 9
#property indicator_color1 C'233,254,233'
#property indicator_width1 17
#property indicator_color2 C'242,236,242'
#property indicator_width2 17
#property indicator_color3 Orange
#property indicator_width3 3
#property indicator_color4 LimeGreen
#property indicator_width4 3
#property indicator_color5 DarkOrchid
#property indicator_width5 3
#property indicator_color6 Orange
#property indicator_width6 2
#property indicator_color7 LimeGreen
#property indicator_width7 2
#property indicator_color8 DarkOrchid
#property indicator_width8 2
#property indicator_color9 Sienna
#property indicator_width9 2
extern int ma_1 = 21;
extern int ma_2 = 120;
extern int ma_3 = 8;
input ENUM_APPLIED_PRICE  price = 0;
input ENUM_MA_METHOD  method_1 = 1;
input ENUM_MA_METHOD  method_2 = 3;
extern int shift_2 = 0;
extern int ТолщинаГимтограммы = 9;
extern int ТолщинаЛинии = 2;
extern bool ShowSignal=false;
extern bool ПоказыватьГистограмму=true;
double ExtMapBuffer1[], ExtMapBuffer2[], MA3[], MA4[], MA5[], MA1[], MA6[], MA7[], MA8[];
int ExtCountedBars=0, key, LineHisto;
//+------------------------------------------------------------------+
int init()  {
   if(ПоказыватьГистограмму) LineHisto=DRAW_HISTOGRAM;   else   LineHisto=DRAW_NONE;
   SetIndexStyle(0,LineHisto, EMPTY, ТолщинаГимтограммы);  SetIndexBuffer(0,ExtMapBuffer1);   SetIndexDrawBegin(0,10);
   SetIndexStyle(1,LineHisto, EMPTY, ТолщинаГимтограммы);  SetIndexBuffer(1,ExtMapBuffer2);   SetIndexDrawBegin(1,10);
   SetIndexStyle(2,DRAW_LINE, EMPTY, ТолщинаЛинии);        SetIndexBuffer(2,MA5);             SetIndexDrawBegin(2,10);
   SetIndexStyle(3,DRAW_LINE, EMPTY, ТолщинаЛинии);        SetIndexBuffer(3,MA3);             SetIndexDrawBegin(3,10);
   SetIndexStyle(4,DRAW_LINE, EMPTY, ТолщинаЛинии);        SetIndexBuffer(4,MA4);             SetIndexDrawBegin(4,10);
   SetIndexStyle(5,DRAW_LINE, EMPTY, ТолщинаЛинии);        SetIndexBuffer(5,MA1);             SetIndexDrawBegin(5,10);
   SetIndexStyle(6,DRAW_LINE, EMPTY, ТолщинаЛинии);        SetIndexBuffer(6,MA6);             SetIndexDrawBegin(6,10);
   SetIndexStyle(7,DRAW_LINE, EMPTY, ТолщинаЛинии);        SetIndexBuffer(7,MA7);             SetIndexDrawBegin(7,10);
   SetIndexStyle(8,DRAW_LINE, EMPTY, ТолщинаЛинии);        SetIndexBuffer(8,MA8);             SetIndexDrawBegin(8,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;
   int cc=0, c;
   while(pos>=0)   { 
      ExtMapBuffer1[pos]=iMA(Symbol(),0,ma_1,0,method_1,price,pos);
      ExtMapBuffer2[pos]=iMA(Symbol(),0,ma_2,shift_2,method_2,price,pos);
      MA8[pos] = iMA(Symbol(),0,ma_3,0,MODE_EMA,PRICE_CLOSE,pos);
      MA1[pos]=ExtMapBuffer1[pos];
      MA5[pos]=ExtMapBuffer2[pos];
      if(ExtMapBuffer1[pos]>=ExtMapBuffer2[pos])    { MA3[pos]=ExtMapBuffer2[pos]; MA4[pos]=EMPTY_VALUE;  MA6[pos]=ExtMapBuffer1[pos];  MA7[pos]=EMPTY_VALUE; }
      if(ExtMapBuffer1[pos]< ExtMapBuffer2[pos])    { MA3[pos]= EMPTY_VALUE;       MA4[pos]=ExtMapBuffer2[pos];    MA7[pos]=ExtMapBuffer1[pos];  MA6[pos]=EMPTY_VALUE; }
 	   pos--;
   }
   if(key!=Time[0] && ShowSignal)  {
     if(High[1]>ExtMapBuffer2[1] && Low[1]<ExtMapBuffer2[1])  {
       for(c=2; c<=15; c++)  if(High[c]>ExtMapBuffer2[c] && Low[c]<ExtMapBuffer2[c]) cc++;
       if(cc==0)  Alert(Symbol(),"   ", Period(), " Пересечение границы Buy-Sell");
     }
     key=Time[0];
   }
   return(0);
}
//+------------------------------------------------------------------+
//for(c=2; c<=12; c++)  if(High[c]>ExtMapBuffer2[c] && Low[c]<ExtMapBuffer2[c]) cc++;
//       if(cc==0)  
