//+------------------------------------------------------------------+
//|   This indicator simply shows the change in percentage between   |
//|    the Close of the current period and the previous one.         |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_separate_window

#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red



//---- buffers
double UpBuffer[];
double DnBuffer[];
//----
int Clen=1;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
   //----                                        
   IndicatorBuffers(2);
   IndicatorDigits(Digits);
//---- indicator line
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,UpBuffer);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,DnBuffer);

  
   
//---- name for DataWindow and indicator subwindow label
   short_name="MT-Coder | Change %";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"Up");
   SetIndexLabel(1,"Down");
  


//----
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//----
 //----
   if(Bars<=Clen) return(0);
//---- 
  
   if(counted_bars>=Clen) i=Bars-counted_bars-1;
   while(i>=0)
     {  

   if(((Close[i]-Close[i+1])/Close[i+1])>=0)
      UpBuffer[i]=((Close[i]-Close[i+1])/Close[i+1])*100;
   else
      DnBuffer[i]=((Close[i]-Close[i+1])/Close[i+1])*100;

i++;
   }
//----

   return(0);
  }
//+------------------------------------------------------------------+