**Dinosatoshi:**I need to know if I have an EA with Heiken Ashi candlestick and indicator with and buy and sell signal, if it’s possible to opens orders in the open in the next HA candle or not

Please note the the Heikin Ashi Open and Close prices are virtual prices (moving average) and not the prices of the current real candle. So when you place the order it will be for the current market prices, not the heikin ashi prices.

You can obviously also place pending orders for the desired prices based on the Heikin Ashi, but there is no guarantee that it will be triggered within a reasonable timespan.

**Dominik Christian Egert #:**

**Dominik Christian Egert #:**Yes, Heikin Ashi is "virtual", but it is not MA based. It is Median Price based, which is the average of (high + low) / 2. So it is technically an average, but not in the sense of a known MA with periods, like SMA 50.

A Heikin Ashi is a exponential moving average (EMA) of period 3 (alpha = 0.5), of the Total Price ( (O+H+L+C)/4 ). It is definitely not median price.

**Dinosatoshi #:**So, can the operations be made to open based on HA's open or not?

No! Not at the open of the bar. Only possible if you wait for the quote to move to the desired price, but by then it may already be a invalid signal or it may never happen at all.

I repeat, Heikin Ashi is just an indicator in the form of a candle. It is not a real candle or bar. It is virtual. It is just an indicator.

**Fernando Carreiro #:**

No! Not at the open of the bar. Only possible if you wait for the quote to move to the desired price, but by then it may already be a invalid signal or it may never happen at all.

I repeat, Heikin Ashi is just an indicator in the form of a candle. It is not a real candle or bar. It is virtual. It is just an indicator.

**Fernando Carreiro #:**

A Heikin Ashi is a exponential moving average (EMA) of period 3 (alpha = 0.5), of the Total Price ( (O+H+L+C)/4 ). It is definitely not median price.

Are you sure???

I cannot find EMA/SMA here:

//+------------------------------------------------------------------+ //| Heiken Ashi | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { int start; //--- preliminary calculations if(prev_calculated==0) { ExtLBuffer[0]=low[0]; ExtHBuffer[0]=high[0]; ExtOBuffer[0]=open[0]; ExtCBuffer[0]=close[0]; start=1; } else start=prev_calculated-1; //--- the main loop of calculations for(int i=start; i<rates_total && !IsStopped(); i++) { double ha_open =(ExtOBuffer[i-1]+ExtCBuffer[i-1])/2; double ha_close=(open[i]+high[i]+low[i]+close[i])/4; double ha_high =MathMax(high[i],MathMax(ha_open,ha_close)); double ha_low =MathMin(low[i],MathMin(ha_open,ha_close)); ExtLBuffer[i]=ha_low; ExtHBuffer[i]=ha_high; ExtOBuffer[i]=ha_open; ExtCBuffer[i]=ha_close; //--- set candle color if(ha_open<ha_close) ExtColorBuffer[i]=0.0; // set color DodgerBlue else ExtColorBuffer[i]=1.0; // set color Red } //--- return(rates_total); } //+------------------------------------------------------------------+

**Dominik Christian Egert #:**You are right, it is not median, but one of the weighted definitions, OHLC/4. Close is OHLC/4. Open is OC/2 (from the previous candle). So, yes, you are right about it not being median. But it is not EMA3 either. Is it?

**Dominik Christian Egert #:**Are you sure??? I cannot find EMA/SMA here:

Yes, I am absolutely sure.

- haClose = ( Open + High + Low + Close) / 4
- haOpen = ( haOpen(previous) + haClose(previous) ) / 2

= haOpen(previous) + 0.5 * ( haClose(previous) - haOpen(previous) ) = μn−1 + α(xn − μn−1) - EMS equation: μn = μn−1 + α(xn − μn−1)
- alpha for period 3 = α = 2 / ( p + 1 ) = 2 / (3 + 1) = 2 /4 = 0.5

The only detail to note is the current haOpen is based on the previous Total Price instead of the current Total Price (data points are shifted by one) but the equation remains the same.

EDIT: Here are the equations in graphic form for easier viewing:

EDIT 2: This is the reason why I publish my *Dōteki Heikin Ashi (Dynamic Average Foot/Bar)* with the variable period, where a period of 3.0 is the default for the original *Heikin Ashi*.

- www.mql5.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets

You agree to website policy and terms of use

Files: