What Heikin-Ashi candlesticks really are, and how to customize them

A lot of years have been spent since Dan Valcu introduced the Heikin-Ashi representation on "Stocks & Commodities". It was on February 2004. Dan Valcu wrote about the calculation:
The heikin-ashi candlestick technique uses modified open-high-low-close (OHLC) values and displays them as candlesticks.
The modified values are computed using these definitions:
1) haClose = (O+H+L+C)/4
2) haOpen = (haOpen (previous bar) + haClose(previous bar))/2
3) haHigh = Maximum(H, haOpen, haClose)
4) haLow = Minimum(L, haOpen, haClose)
Since those days nobody noticed that formulas 3) and 4) state redundant calculations.
More simple they are:

3) haHigh = Maximum(H, haOpen)
4) haLow = Minimum(L, haOpen)

That’s because haClose is always between H and L. 14 years were spent but nobody on the internet pointed it out.

Another thing to notice is the real meaning of haOpen. haOpen really is an exponential moving average of the haClose(previous bar).

Let’s write the calculation formula in Amibroker Formula Language (AFL), the code is:
haClose = (O+H+L+C)/4;
haOpen = ema(Ref(haClose, -1), 3);
haHigh = Max(H, haOpen);
haLow = Min(L, haOpen);
Heikin-Ashi is nothing else than charting averaged prices as candlesticks, what an Heikin-Ashi chart shows is often very far from real prices, as averages usually do. 

You can change the number of periods of the exponential moving average (ema) from three to two, or to four or as you want and customize the Heikin-Ashi representation.

Comments

  1. This comment has been removed by a blog administrator.

    ReplyDelete

Post a Comment

Popular Posts