I am trying to code a simple indicator showing the uptick and downtick histo seperately. Unfortunatels it seems it shows only the upticks. This is the code i am using
Code: Select all
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 ForestGreen
#property indicator_color2 OrangeRed
double Uptick[];
double Dntick[];
//+------------------------------------------------------------------+
//| indicator initialization |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("VolumeDif("+Symbol()+")");
SetIndexBuffer(0,Uptick);
SetIndexBuffer(1,Dntick);
SetIndexStyle(0,DRAW_HISTOGRAM,0,2);
SetIndexStyle(1,DRAW_HISTOGRAM,0,2);
return(0);
}
//+------------------------------------------------------------------+
//| indicator deinitialization |
//+------------------------------------------------------------------+
int deinit()
{
//----
return(0);
}
//+------------------------------------------------------------------+
//| indicator function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
int i,limit;
//----
if(counted_bars==0)
limit=Bars-1;
if(counted_bars>0)
limit=Bars-counted_bars;
limit--;
for(i=limit; i>=0; i--)
Uptick[i]=(Volume[i]+(Close[i]-Open[i])/Point)/2;
Dntick[i]=-Volume[i]+(Volume[i]+(Close[i]-Open[i])/Point)/2;
//----
return(0);
}
//+------------------------------------------------------------------+