//+------------------------------------------------------------------+
//|                                                   HLC Volume.mq4 |
//+------------------------------------------------------------------+
#property indicator_separate_window

#property indicator_buffers 2
#property indicator_minimum 0

#property indicator_color1 Lime
#property indicator_color2 Red

#property indicator_width1 2
#property indicator_width2 2



//Volume buffers
double UpBar[], DownBar[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   IndicatorDigits(0);
   SetIndexStyle(0, DRAW_HISTOGRAM);
   SetIndexBuffer(0, UpBar);
   SetIndexLabel(0, "Up Bar");
   SetIndexStyle(1, DRAW_HISTOGRAM);
   SetIndexBuffer(1, DownBar);
   SetIndexLabel(1, "Down Bar");
   IndicatorShortName("HLC Volume"); 

   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
{

   int limit,
       counted_bars = IndicatorCounted();
   
   if (counted_bars>0) counted_bars--;
   limit = Bars - counted_bars;

   for (int i = 0; i < limit; i++)
   {
      if (Close[i] > Close[i+1])
      {
         UpBar[i] = Volume[i];
         DownBar[i] = 0;
      }
      else 
      {
         DownBar[i] = Volume[i];
         UpBar[i] = 0;
      }
   }
   return(0);
}
//+------------------------------------------------------------------+