modified osma to try and get difference between 2 moving averages

 

I'm trying to get a histogram to show the differences bbetween 2 moving averages. I modified the OsMa for this but am not sure i have the buffers right for the drawing? It seems to draw it correctly but somehow the code doesn't seem correct:


//+------------------------------------------------------------------+
//|                                                         OsMA.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property  copyright "Copyright © 2004, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 1
#property  indicator_color1  Silver
#property  indicator_width1  2
//---- indicator parameters
extern int FastSMA=5;
extern int SlowSMA=10;
//---- indicator buffers
double     FastBuffer[];
double     SlowBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 2 additional buffers are used for counting.
   IndicatorBuffers(3);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   //SetIndexDrawBegin(0,Histo);
   IndicatorDigits(Digits+2);
//---- 3 indicator buffers mapping
   SetIndexBuffer(0,FastBuffer);
   SetIndexBuffer(1,SlowBuffer);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("SMA Diffs("+FastSMA+","+SlowSMA+")");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Average of Oscillator                                     |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- macd counted in the 1-st additional buffer
   for(int i=0; i<limit; i++)
      FastBuffer[i]=MathAbs(iMA(NULL,0,FastSMA,0,MODE_SMA,PRICE_CLOSE,i)-iMA(NULL,0,SlowSMA,0,MODE_EMA,PRICE_CLOSE,i));
//---- done
   return(0);
  }
//+------------------------------------------------------------------+
Reason: