//+------------------------------------------------------------------+
//|                                            Density Histogram.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
#property indicator_width1 2
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_level1 50

double buff[];

int init()
{
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,buff);
IndicatorDigits(Digits+1);
return(0);
}

int start()
{
int i,counted_bars=IndicatorCounted();
if(counted_bars>0) counted_bars--;
i=Bars-counted_bars;
while(i>=0)
{
double range = MathAbs(High[i]-Low[i]);
if(range>0) buff[i] = 100*MathAbs(Open[i]-Close[i])/range;
else buff[i] = 0;
i--;
}
return(0);
} 