Download MetaTrader 5

Heiken ash mql4 folmula please.

To add comments, please log in or register
prweza
303
prweza  

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.

Taras Slobodyanik
19569
Taras Slobodyanik  
      //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;
prweza
303
prweza  
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.

Taras Slobodyanik
19569
Taras Slobodyanik  

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.

whroeder1
16286
whroeder1  
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.
To add comments, please log in or register