//+------------------------------------------------------------------+
//|                                                   iMAOnArray.mq4 |
//|                                                      Coders Guru |
//|                                       http://www.metatrader.info |
//+------------------------------------------------------------------+

#property copyright "Coders Guru"
#property link      "http://www.metatrader.info"


#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LawnGreen
#property indicator_color2 DarkBlue
//---- input parameters
extern int ATRPeriod=6;
extern int MAPeriod=20;
extern int MAMode = MODE_SMA;
double ExtMapBuffer1[];
double ExtMapBuffer2[];

int init()
  {
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(1,ExtMapBuffer2);
  
   return(0);
  }

int deinit()
  {
   return(0);
  }
  
int start()
  {
   int bar, limit;
   
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-IndicatorCounted();
    
   
   for(bar=0; bar<limit; bar++)
      ExtMapBuffer1[bar] = iATR(NULL,0,ATRPeriod,bar);
  
   for(bar=0; bar<limit; bar++)
         ExtMapBuffer2[bar]=iMAOnArray(ExtMapBuffer1,Bars,MAPeriod,0,MAMode,bar);
   
   return(0);
  }