Recreating heiken ashi candles with moving averages

 

Is there an easy way to recreate heiken ashi candles using moving averages? The code for heiken ashi candles themselves is a bit involved. As the calculation is basicly working out a moving average cross I wonder if anyone knows the best two ma's and settings to use?

I have an alert dashboard already coded which uses moving averages so it would be very easy just to change the ma settings to get it to do what I want. Thanks. 

 
heikin_ashi. Theres another thread about HA running next to this one. Perhaps the both of you can exchange ideas. There's nothing mql4 or automated about these topics. Perhaps you can OverLay a Moving_Average on heikin_ashi and get your answers that way.
 

Ok, thanks.

 
hughbriss:

Is there an easy way to recreate heiken ashi candles using moving averages? The code for heiken ashi candles themselves is a bit involved. As the calculation is basicly working out a moving average cross I wonder if anyone knows the best two ma's and settings to use?

I have an alert dashboard already coded which uses moving averages so it would be very easy just to change the ma settings to get it to do what I want. Thanks. 


Open Heikin Ashi in MetaEditor, and do this

1. Do these find and add 

#property indicator_width3 3  //<--- find this
#property indicator_width4 3  //<--- find this

//----
extern int   ma_period= 5;    //<<-- add this
extern int   ma_method=MODE_SMMA; //<<-- add this
extern int   ma_shift=0;      //<<-- add this
extern color color1 = Red;    //<--- find this
extern color color2 = White;  //<--- find this

2. Find these

haClose=(Open[pos]+High[pos]+Low[pos]+Close[pos])/4;
haHigh=MathMax(High[pos], MathMax(haOpen, haClose));
haLow=MathMin(Low[pos], MathMin(haOpen, haClose));

 ... and replace them with these 

haClose=(ma (PRICE_OPEN, pos)+ma (PRICE_HIGH, pos)+ma (PRICE_LOW, pos)+ma (PRICE_CLOSE, pos))/4;
haHigh=MathMax(ma (PRICE_HIGH, pos), MathMax(haOpen, haClose));
haLow=MathMin(ma (PRICE_LOW, pos), MathMin(haOpen, haClose));

3. Do find and add again

      ExtMapBuffer3[pos]=haOpen;   //<--- Find this
      ExtMapBuffer4[pos]=haClose;  //<--- Find this
           pos--;                  //<--- Find this
     }                             //<--- Find this
//----
   return(0);                      //<--- Find this       
  }                                //<--- Find this 
//+------------------------------------------------------------------+
double ma (int price_type, int bar)                                                    //<<-- add this
  {                                                                                    //<<-- add this
  return (iMA (Symbol(), Period(), ma_period, ma_shift, ma_method, price_type, bar));  //<<-- add this
  }                                                                                    //<<-- add this

 4. Click compile or press F7 to compile, if there are no error then you are ready to go.

 

Excellent, thanks. So it's a bit more complicated than just a straight ma but by using the 5 smoothed ma and calculating the haopen, close, etc from that then it achieves the same. Nice.

Reason: