//+------------------------------------------------------------------+
//|                                           iMAOnArray_Example.mq4 |
//|                                         Copyright © 2011, Kirill |
//|                                          StockProgrammer@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Kirill"
#property link      "StockProgrammer@mail.ru"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 DarkBlue
#property indicator_level1 55 
#property indicator_level2 45
#property indicator_levelcolor Orange

double ExtMapBuffer1[];
double ExtMapBuffer2[];

extern int period_RSI = 10;
extern int price_RSI = PRICE_CLOSE;

extern int period_MA = 10;
extern int price_MA = MODE_SMA;
int init()
{
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,YellowGreen);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,0,DodgerBlue);
   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] = iRSI(NULL,0,period_RSI,price_RSI,bar);
  
   for(bar=0; bar<limit; bar++)
      ExtMapBuffer2[bar]=iMAOnArray(ExtMapBuffer1,Bars,period_MA,0,price_MA,bar);
   
   return(0);
}