//+------------------------------------------------------------------+
//|                                                     MA Canal.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
 
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Lime
#property indicator_color2 Black
#property indicator_width1 6
#property indicator_width2 6
//----
extern color color1 = Lime;
extern color color2 = Black;
extern int period = 34;

extern int method = 1;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];

//----
int ExtCountedBars=0;
//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, 6, color1);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, 6, color1);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE,0,3, color2);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexStyle(3,DRAW_LINE,0,3, color2);
   SetIndexBuffer(3, ExtMapBuffer4);
   SetIndexStyle(4,DRAW_LINE,2,2, color2);
   SetIndexBuffer(4, ExtMapBuffer5);
   
   IndicatorShortName("MA Canal");
   
   
//----
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
     

 
   return(0);
  }
//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
int start()
  {
   if(Bars<=10) return(0);
   ExtCountedBars=IndicatorCounted();
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   int pos=Bars-ExtCountedBars-1;
   while(pos>=0)
     { 
      ExtMapBuffer1[pos]=iMA(Symbol(),0,period,0,method,PRICE_HIGH,pos);
      ExtMapBuffer2[pos]=iMA(Symbol(),0,period,0,method,PRICE_LOW,pos);
      ExtMapBuffer3[pos]=iMA(Symbol(),0,period,0,method,PRICE_HIGH,pos);
      ExtMapBuffer4[pos]=iMA(Symbol(),0,period,0,method,PRICE_LOW,pos);
      ExtMapBuffer5[pos]=iMA(Symbol(),0,period,0,method,PRICE_CLOSE,pos);
      
        pos--;
     }
//----
   return(0);
  }
//\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n