Heikin-Ashi Candlesticks are an offshoot from Japanese candlesticks. Heikin-Ashi Candlesticks use the open-close data from the prior period and the open-high-low-close data from the current period to create a combo candlestick. The resulting candlestick filters out some noise in an effort to better capture the trend. In Japanese, Heikin means "average" and "ashi" means "pace" (EUDict.com). Taken together, Heikin-Ashi represents the average-pace of prices. Heikin-Ashi Candlesticks are not used like normal candlesticks. Dozens of bullish or bearish reversal patterns consisting of 1-3 candlesticks are not to be found. Instead, these candlesticks can be used to identify trending periods, potential reversal points and classic technical analysis patterns.

More Information about:
Link: 1) http://stockcharts.com/help/doku.php?id=chart_school:chart_analysis:heikin_ashi




Calculation:

1. The Heikin-Ashi Close is simply an average of the open,
high, low and close for the current period.

HA-Close = (Open(0) + High(0) + Low(0) + Close(0)) / 4

2. The Heikin-Ashi Open is the average of the prior Heikin-Ashi
candlestick open plus the close of the prior Heikin-Ashi candlestick.

HA-Open = (HA-Open(-1) + HA-Close(-1)) / 2

3. The Heikin-Ashi High is the maximum of three data points:
the current period's high, the current Heikin-Ashi
candlestick open or the current Heikin-Ashi candlestick close.

HA-High = Maximum of the High(0), HA-Open(0) or HA-Close(0)

4. The Heikin-Ashi low is the minimum of three data points:
the current period's low, the current Heikin-Ashi
candlestick open or the current Heikin-Ashi candlestick close.

HA-Low = Minimum of the Low(0), HA-Open(0) or HA-Close(0)



Source Code "The Heikin-Ashi":

// HeikinAshi -

function init()
{
with (HeikinAshi) {
createParameter("Opacity", 100);
}
}

function start()
{
HeikinAshi.label = "HeikinAshi";
Op = 0.01 * HeikinAshi.parameter("Opacity");

var num = Shared.numberOfQuotes();

bufClose = Shared.close();
bufOpen = Shared.open();
bufHigh = Shared.high();
bufLow = Shared.low();

haClose = new Array(num);
haOpen = new Array(num);
haHigh = new Array(num);
haLow = new Array(num);

haClose[0] = bufClose[0];
haOpen[0] = bufOpen[0];

for (var i = 1 ; i < num; ++i) {
haClose[i] = (bufOpen[i] + bufHigh[i] + bufLow[i] + bufClose[i]) / 4;
haOpen[i] = (haOpen[i-1] + haClose[i-1]) / 2;

haHigh[i] = Math.max(bufHigh[i], haOpen[i], haClose[i]);
haLow[i] = Math.min(bufLow[i], haOpen[i], haClose[i]);;
}

}

function draw()
{

Painter.setOpacity(Op);

var nPosition = Shared.firstVisiblePosition()+1; // Определить первую видимую квоту

var kolvo = Shared.numberOfVisibleQuotes() ; // число видимых квот

max = haHigh[nPosition];
min = haLow[nPosition];
//---------------------------------------------------
// определить минимум и максимум

for ( i =0; i < kolvo; ++i) {
if (haHigh[i+nPosition-1] > max ) max = haHigh[i+nPosition-1];
if (haLow[i+nPosition]-1 > max ) max = haLow[i+nPosition-1];
if (haHigh[i+nPosition-1] < min ) min = haHigh[i+nPosition-1];
if (haLow[i+nPosition-1] < min ) min = haLow[i+nPosition-1];
}

//установить высоту
HeikinAshi.setMax(max);
HeikinAshi.setMin(min);

//-----------------------------------------------------------

delta = Shared.zoom(); // Графический шаг
maxDisplay=Shared.height();
koef = maxDisplay /(max-min);

for ( i =0; i < kolvo; ++i) {
nn = nPosition+i-1;

if (haOpen[nn] {
Painter.setBrush("blue", BrushStyle.SolidPattern);
Painter.setPen('blue', 1, PenStyle.SolidLine);
}
else
{
Painter.setBrush("red", BrushStyle.SolidPattern);
Painter.setPen('red', 1, PenStyle.SolidLine);
}

Painter.drawLine(i*delta, (max - haHigh[nn])*koef, i*delta, (max-haLow[nn])*koef);
Painter.drawRect(i*delta - delta*0.35, (max - haOpen[nn])*koef, delta*0.7, (haOpen[nn]-haClose[nn]) *koef);
}

}