#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  LimeGreen
#property indicator_color2  Orange
#property indicator_width1  2
#property indicator_width2  2

//
//
//
//
//

extern int MaPeriod =  14;
extern int MaMethod =  MODE_SMA;
extern int MaPrice  =  PRICE_CLOSE;
extern int Price    =  PRICE_CLOSE;

//
//
//
//
//

double up[];
double dn[];

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

int init()
{
   SetIndexBuffer(0,up); SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(1,dn); SetIndexStyle(1,DRAW_HISTOGRAM);
   return(0);
}
int deinit() { return(0); }

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      if(counted_bars>0) counted_bars--;
         int limit = MathMin(Bars-counted_bars,Bars-1);
         double pipMultiplier = MathPow(10,MathMod(Digits,2));

   //
   //
   //
   //
   //
   //

   for(int i=limit; i >= 0; i--)
   {
      double diff = (iMA(NULL,0,1,0,MODE_SMA,Price,i)-iMA(NULL,0,MaPeriod,0,MaMethod,MaPrice,i))/(pipMultiplier*Point);
      if (diff>0)
            { up[i] = diff; dn[i] = EMPTY_VALUE; }
      else  { dn[i] = diff; up[i] = EMPTY_VALUE; }
   }         
   return(0);
}

