//+------------------------------------------------------------------+
//|                                                b4rhep volume.mq4 |
//+------------------------------------------------------------------+

#property indicator_separate_window

#property  indicator_buffers 3
#property  indicator_color1  Green
#property  indicator_width1  3
#property  indicator_color2  Red
#property  indicator_width2  3
#property  indicator_color3  Yellow
#property  indicator_width3  3

extern  int     LookbackBars   = 99999;
extern  int     BarWidth       = 3;
extern  color   BullColor      = Green;
extern  color   BearColor      = Red;
extern  color   NeutralColor   = Yellow;

double   ind_buffer0[], ind_buffer1[], ind_buffer2[];

//+------------------------------------------------------------------+
int init()  {
//+------------------------------------------------------------------+
  SetIndexBuffer(0,ind_buffer0);
  SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,BarWidth,BullColor);

  SetIndexBuffer(1,ind_buffer1);
  SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,BarWidth,BearColor);

  SetIndexBuffer(2,ind_buffer2);
  SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,BarWidth,NeutralColor);

  return(0);
}

//+------------------------------------------------------------------+
int deinit()  {
//+------------------------------------------------------------------+
  return(0);
}

//+------------------------------------------------------------------+
int start()  {
//+------------------------------------------------------------------+
  for (int i=0; i<MathMin(Bars,LookbackBars); i++)  {
    ind_buffer0[i] = EMPTY_VALUE;
    ind_buffer1[i] = EMPTY_VALUE;
    ind_buffer2[i] = EMPTY_VALUE;
    if (Close[i] > Open[i])   ind_buffer0[i] = Volume[i];   else
    if (Close[i] < Open[i])   ind_buffer1[i] = Volume[i];   else
    ind_buffer2[i] = Volume[i];
  }
  return(0);
}

