Help with Heikin Ashi indicator!

 
I would like to modify the existing Heikin ashi indicator to draw an arrow whenever there's a colour change (signifying a change in trend). But it's not working and I cant identify the problem. Please help and thanks in advance!
Files:
 
jaspernjm:
I would like to modify the existing Heikin ashi indicator to draw an arrow whenever there's a colour change (signifying a change in trend). But it's not working and I cant identify the problem. Please help and thanks in advance!

Hi,

 

I think your counting is wrong:

   int counted_bars=IndicatorCounted();
   int limit= Bars-counted_bars;
   for(int k=(Bars-100);k>limit;k--)
     {
      //if gray then black
      if(openb[k+1]<closeb[k+1] && openb[k]>closeb[k])
         downarrow[k]=closeb[k];
      //else if black then gray
      else if(openb[k+1]>closeb[k+1] && openb[k]<closeb[k])
         uparrow[k]=closeb[k];
     }

 

It works this way:

    for (bar=limit; bar>=0 && !IsStopped(); bar--)
     {
      if((ExtOpenBuffer[bar-1]<ExtCloseBuffer[bar-1]) && (ExtOpenBuffer[bar]>ExtCloseBuffer[bar]))
        {
         downarrow[bar]=MathMax(ExtLowHighBuffer[bar],ExtHighLowBuffer[bar])+(50*Point);
         uparrow[bar]=EMPTY_VALUE;
        }
      if((ExtOpenBuffer[bar-1]>ExtCloseBuffer[bar-1]) && (ExtOpenBuffer[bar]<ExtCloseBuffer[bar]))
        {
         uparrow[bar]=MathMin(ExtLowHighBuffer[bar],ExtHighLowBuffer[bar])-(50*Point);
         downarrow[bar]=EMPTY_VALUE;
        }
     }

The arrow alignment is different, too, as you see.

Reason: