//+------------------------------------------------------------------+
//|                                     Range Body in Tick Value.mq4 |
//|                                                for everyone inc. |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "for everyone inc."
#property link      ""

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  clrSteelBlue
#property indicator_width1  3
#property indicator_color2  clrIndianRed
#property indicator_width2  3

double Up[];
double Dn[];

int PipFactor = 1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,Up);
   SetIndexLabel(0,"Up Candle");
    SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,Dn);
   SetIndexLabel(1,"Down Candle");
     
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("Range Body in Tick Value  ");
   IndicatorDigits(1);
   // Cater for fractional pips
   if (Digits == 3 || Digits == 5)
   {
      PipFactor = 1;
   }
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

   for(int i=0; i<limit;i++){
      Up[i]=0;
      Dn[i]=0;
      double Range_Buffer=((Close[i]-Open[i])/Point)/PipFactor;
      if(Range_Buffer>0) Up[i]=Range_Buffer; else Dn[i]=Range_Buffer;}
//---- done
   return(0);
  }
//+------------------------------------------------------------------+