//+------------------------------------------------------------------+
//
//+------------------------------------------------------------------+


#property  copyright ""
#property  link      ""


#property  indicator_separate_window
#property  indicator_buffers 2
#property  indicator_color1  RoyalBlue
#property  indicator_color2  OrangeRed

#property  indicator_minimum 0
#property  indicator_maximum 5



extern int TimeFrame=0;
extern int macdMAfast =12;  
extern int macdMAslow =26;  
extern int macdSigMA  =9;  

double buffer1[];
double buffer2[];


int init()
  {
   

    SetIndexStyle(0,DRAW_ARROW);    SetIndexArrow(0,167);    SetIndexBuffer(0,buffer1);    SetIndexEmptyValue(0,EMPTY_VALUE);
   
    SetIndexStyle(1,DRAW_ARROW);    SetIndexArrow(1,167);    SetIndexBuffer(1,buffer2);    SetIndexEmptyValue(1,EMPTY_VALUE);
   



   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++)
      {

      double       macdm =iMACD(NULL,TimeFrame,macdMAfast,macdMAslow,macdSigMA,PRICE_CLOSE,0,i);
      double       macds =iMACD(NULL,TimeFrame,macdMAfast,macdMAslow,macdSigMA,PRICE_CLOSE,1,i);
       
                        buffer1[i]=EMPTY_VALUE;    buffer2[i]=EMPTY_VALUE;

      if (macdm>macds)  buffer1[i]=1;      else    buffer2[i]=1;



      }
   return(0);
  }















