backtrader.indicators.heikinashi module¶
Heikin Ashi Indicator Module - Heikin Ashi candlesticks.
This module provides the Heikin Ashi candlestick indicator which creates alternative candlestick charts for trend identification.
- Classes:
HeikinAshi: Heikin Ashi candlestick lines.
示例
- class MyStrategy(bt.Strategy):
- def __init__(self):
self.ha = bt.indicators.HeikinAshi(self.data)
- def next(self):
# Use Heikin Ashi close for trend analysis if self.data.close[0] > self.ha.ha_close[0]:
self.buy()
- class backtrader.indicators.heikinashi.HeikinAshi[源代码]¶
基类:
IndicatorHeikin Ashi candlesticks in the forms of lines
- Formula:
ha_open = (ha_open(-1) + ha_close(-1)) / 2 ha_high = max (hi, ha_open, ha_close) ha_low = min (lo, ha_open, ha_close) ha_close = (open + high + low + close) / 4
参见
https://en.wikipedia.org/wiki/Candlestick_chart#Heikin_Ashi_candlesticks http://stockcharts.com/school/doku.php?id=chart_school:chart_analysis:heikin_ashi
- linealias = (('ha_open', 'open'), ('ha_high', 'high'), ('ha_low', 'low'), ('ha_close', 'close'))¶
- plotinfo = <backtrader.metabase.plotinfo_obj object>¶
- __init__(*args, **kwargs)¶
- next()[源代码]¶
Calculate Heikin Ashi values for the current bar.
Calculates ha_close, ha_open, ha_high, and ha_low using: - ha_close = (open + high + low + close) / 4 - ha_open = (prev_ha_open + prev_ha_close) / 2 - ha_high = max(high, ha_open, ha_close) - ha_low = min(low, ha_open, ha_close)
- prenext()[源代码]¶
Calculate Heikin Ashi values before minimum period is reached.
Uses the same calculation as next() to show values from the start.
- frompackages = ()¶
- packages = ()¶