//+------------------------------------------------------------------+
//|                             Simple_EMA_Indicator_MrC_Nov,12,2012 |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Magenta
#property indicator_color2 Orange
#property indicator_color3 DodgerBlue
#property indicator_color4 White

extern string MA_method="0=SMA.1=EMA.2=SmthMA.3=LWMA";
extern int Selected_Method= 1;
extern string Apply_to="0=Close.1=Open.2=High.3=Low...";
extern int Selected_PriceType= 0;
extern string To_Disable_MA_Set_Period_to_0;
extern int MA_Period1=200;
extern int MA_Shift1=0;
extern int MA_Period2=50;
extern int MA_Shift2=0;
extern int MA_Period3=10;
extern int MA_Shift3=0;
extern int MA_Period4=800;
extern int MA_Shift4=0;

double ExtMA_1Buffer[];
double ExtMA_2Buffer[];
double ExtMA_3Buffer[];
double ExtMA_4Buffer[];

int init()
  {

   SetIndexShift(0,MA_Shift1);
   SetIndexShift(1,MA_Shift2);
   SetIndexShift(2,MA_Shift3);
   SetIndexShift(3,MA_Shift4);

   SetIndexDrawBegin(0,MA_Shift1+MA_Period1);
   SetIndexDrawBegin(1,MA_Shift2+MA_Period2);
   SetIndexDrawBegin(2,MA_Shift3+MA_Period3);
   SetIndexDrawBegin(3,MA_Shift4+MA_Period4);

   SetIndexBuffer(0,ExtMA_1Buffer);
   SetIndexBuffer(1,ExtMA_2Buffer);
   SetIndexBuffer(2,ExtMA_3Buffer);
   SetIndexBuffer(3,ExtMA_4Buffer);

   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexStyle(3,DRAW_LINE);

   SetIndexLabel(0,"200_MA");
   SetIndexLabel(1,"50_MA");
   SetIndexLabel(2,"10_MA");
   SetIndexLabel(3,"800_MA");

   return(0);
  }

int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();

   if(counted_bars<0) return(-1);

   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(int i=0; i<limit; i++)
     {
     
      ExtMA_1Buffer[i]=iMA(NULL,0,MA_Period1,0,Selected_Method,Selected_PriceType,i);
      ExtMA_2Buffer[i]=iMA(NULL,0,MA_Period2,0,Selected_Method,Selected_PriceType,i);
      ExtMA_3Buffer[i]=iMA(NULL,0,MA_Period3,0,Selected_Method,Selected_PriceType,i);
      ExtMA_4Buffer[i]=iMA(NULL,0,MA_Period4,0,Selected_Method,Selected_PriceType,i);
     }

   return(0);
  }



