//+------------------------------------------------------------------+
//|      indicator  to see if Ma Fast  is above or below Ma Slow   
/////////   HISTOGRAM  
//|                    by Sohocool le 02/2012  |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
// 

#property  copyright "Copyright © 2008, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1

#property  indicator_buffers 3
#property  indicator_color1  Yellow
#property  indicator_color2  Red
#property  indicator_color3  SkyBlue
//---- indicator parameters      
extern int Ma_Fast=63;
extern int Price=0;
extern int  Ma_Mode =1;
extern int Ma_Slow=165;

//---- indicator buffers
double   ExtBuffer1[];
double   ExtBuffer2[];
double   ExtBuffer3[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle (0,DRAW_HISTOGRAM, EMPTY,4,Yellow);
   SetIndexBuffer(0,ExtBuffer1);
   SetIndexStyle (1,DRAW_HISTOGRAM, EMPTY,4,Red);
   SetIndexBuffer(1,ExtBuffer2);
   SetIndexStyle (2,DRAW_HISTOGRAM, EMPTY,4,SkyBlue);
   SetIndexBuffer(2,ExtBuffer3);
//---- names
   IndicatorShortName("Ma Fast/Slow "+Ma_Fast+" / "+Ma_Slow+"");
   SetIndexLabel(0,"Ma "+Ma_Fast +" is ABOVE "+Ma_Slow+"");
   SetIndexLabel(1,"Ma "+Ma_Fast+" is BELOW "+Ma_Slow+"");
   SetIndexLabel(2,"Ma "+Ma_Fast+" is EGAL "+Ma_Slow+"");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages                                                  |
//+------------------------------------------------------------------+
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 1st buffer
   for(int i=0; i<limit; i++)
       if (iMA(NULL,0,Ma_Fast,0,Ma_Mode,Price,i)<iMA(NULL,0,Ma_Slow,0,Ma_Mode,Price,i) ) 
        {
        ExtBuffer2[i]=1;
        }
       else
       if (iMA(NULL,0,Ma_Fast,0,Ma_Mode,Price,i)>iMA(NULL,0,Ma_Slow,0,Ma_Mode,Price,i) ) 
        {
        ExtBuffer1[i]=1;
        }
       else 
        ExtBuffer3[i]=1;
   
   return(0);
  }
  
//+------------------------------------------------------------------+