ha#

API documentation for pandas_ta.candles.ha Python function.

ha(open_, high, low, close, offset=None, **kwargs)[source]#

Heikin Ashi Candles (HA)

The Heikin-Ashi technique averages price data to create a Japanese candlestick chart that filters out market noise. Heikin-Ashi charts, developed by Munehisa Homma in the 1700s, share some characteristics with standard candlestick charts but differ based on the values used to create each candle. Instead of using the open, high, low, and close like standard candlestick charts, the Heikin-Ashi technique uses a modified formula based on two-period averages. This gives the chart a smoother appearance, making it easier to spots trends and reversals, but also obscures gaps and some price data.

Sources:

https://www.investopedia.com/terms/h/heikinashi.asp

Calculation:

HA_OPEN[0] = (open[0] + close[0]) / 2 HA_CLOSE = (open[0] + high[0] + low[0] + close[0]) / 4

for i > 1 in df.index:

HA_OPEN = (HA_OPEN[i−1] + HA_CLOSE[i−1]) / 2

HA_HIGH = MAX(HA_OPEN, HA_HIGH, HA_CLOSE) HA_LOW = MIN(HA_OPEN, HA_LOW, HA_CLOSE)

How to Calculate Heikin-Ashi

Use one period to create the first Heikin-Ashi (HA) candle, using the formulas. For example use the high, low, open, and close to create the first HA close price. Use the open and close to create the first HA open. The high of the period will be the first HA high, and the low will be the first HA low. With the first HA calculated, it is now possible to continue computing the HA candles per the formulas.

​​ Args:

open_ (pd.Series): Series of ‘open’s high (pd.Series): Series of ‘high’s low (pd.Series): Series of ‘low’s close (pd.Series): Series of ‘close’s

Kwargs:

fillna (value, optional): pd.DataFrame.fillna(value) fill_method (value, optional): Type of fill method

Returns:

pd.DataFrame: ha_open, ha_high,ha_low, ha_close columns.