Help with Heikin Ashi indicator!

Back to topics list To post a new topic, please log in or register
avatar
1
jaspernjm 2015.08.08 18:16
 
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!
Attached files:
  hachangedv2.mq4  (6.01 KB)
avatar
54
PomeGranate 2015.08.10 12:49 #
 
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.

 

Back to topics list  

To add comments, please log in or register