Drawing the MACD Histogram

 
I would like to draw the MACD histigram bars different colors based on the value of the bar.
It seems that the histogram bars are drawn in the color of the last condition. Is there
a way to draw the bars one bar at a time using a particular color?

Code snippet

if (MacdBuffer[i] > 0.0 )
SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, EMPTY, Green);
else if (MacdBuffer[i] < 0.0 )
SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, EMPTY, FireBrick);

How can I fix this to get the results I'm trying to get.

Thanks,

Steve
 
Draw is the process after all buffers had calcaulated, so can change color no effect during calculation.


should be :
init()
{......
        SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, EMPTY, Green);
    SetIndexStyle(1, DRAW_HISTOGRAM, EMPTY, EMPTY, FireBrick);
  SetIndexBuffer(0,GreenBuffer);
   SetIndexBuffer(1,FireBrickBuffer);
......
}
start()
{
......
  if (MacdBuffer[i] > 0.0 )
      GreenBuffer[i] = MacdBuffer[i] ;
        else if (MacdBuffer[i] < 0.0 )
          FireBrickBuffer[i] = MacdBuffer[i] ;
 
I've tried this code but now it is not drawing anything. Exactly where in my code should the calulations be. i.e. macd_buffer[i] = iMA(...)


DxdCn wrote:

Draw is the process after all buffers had calcaulated, so can change color no effect during calculation.


should be :
init()
{......
        SetIndexStyle(0, DRAW_HISTOGRAM, EMPTY, EMPTY, Green);
    SetIndexStyle(1, DRAW_HISTOGRAM, EMPTY, EMPTY, FireBrick);
  SetIndexBuffer(0,GreenBuffer);
   SetIndexBuffer(1,FireBrickBuffer);
......
}
start()
{
......
  if (MacdBuffer[i] > 0.0 )
      GreenBuffer[i] = MacdBuffer[i] ;
        else if (MacdBuffer[i] < 0.0 )
          FireBrickBuffer[i] = MacdBuffer[i] ;

 
Has this been resolved? I'm tzrying too, but only one half of the Histogram is actually drawn - in black!
Reason: