//+------------------------------------------------------------------+
//|                                                          MA2.mq4 |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Red
//----
extern int MA1_Period=5;
extern int MA2_Period=9;
double ExtMapBuffer[];
int ExtCountedBars=0;
//+------------------------------------------------------------------+
int init()
{
   int draw_begin;
   SetIndexStyle(0,DRAW_LINE);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   draw_begin=MA2_Period-1;
   SetIndexDrawBegin(0,draw_begin);
   SetIndexBuffer(0,ExtMapBuffer);
   return(0);
}
//+------------------------------------------------------------------+
int start()
{
int i,pos=Bars-ExtCountedBars-1;
   if(Bars<=MA2_Period) return(0);
   ExtCountedBars=IndicatorCounted();
   if (ExtCountedBars<0) return(-1);
   if (ExtCountedBars>0) ExtCountedBars--;
   while(pos>=0)
   {
      ExtMapBuffer[pos]=2*iMA(NULL,0,MA1_Period,0,MODE_LWMA,PRICE_MEDIAN,pos)-iMA(NULL,0,MA2_Period,0,MODE_LWMA,PRICE_MEDIAN,pos);
      pos--;
   }
   return(0);
}
//+------------------------------------------------------------------+

