Heiken ash mql4 folmula please.

 

Hi please help,

I'm looking for a mql4 formula for a red and green candle for the heiken ash indicator. I'm currently using an icustom for the HA indicator but this this slows the system especially  during testing. Grateful if someone could give me a  calculation in mql4 code.

Thanks.

 
      //Heiken Ashi
      haOpen=(open_ashi[i+1]+close_ashi[i+1])/2;
      haClose=(open[i]+high[i]+low[i]+close[i])/4;
      haHigh=MathMax(high[i],MathMax(haOpen,haClose));
      haLow=MathMin(low[i],MathMin(haOpen,haClose));
      
      open_ashi[i]=haOpen;
      close_ashi[i]=haClose;
      high_ashi[i]=haHigh;
      low_ashi[i]=haLow;
 
Taras Slobodyanik:


thanks Taras Slobodyanik:so for a red candle

red candle = haOpen< haClose , is this correct? Also if i want to see the red candle for the previous bar ( shift 1) how do i amend the above formulas?


Thanks very much.

 

red candle = haOpen< haClose , is this correct? Also if i want to see the red candle for the previous bar ( shift 1) how do i amend the above formulas?

haOpen < haClose = bullish candle
haOpen > haClose = bearish candle

I think it's best to count the whole history, because the current data depends on the previous ones. 
So you need to count four buffers - 

open_ashi[i]; 
close_ashi[i]; 
high_ashi[i]; 
low_ashi[i];

And then you can take any necessary values from the buffers.

 
prweza: I'm currently using an icustom for the HA indicator but this this slows the system especially  during testing.
  1. It's not your indicator, it's your EA
  2. Don't do per tick what you can do per bar.
Reason: