fixed: heikinashi worked in backtesting, but failed in tests with testing arrays
This commit is contained in:
parent
d642e03cd0
commit
2554ebf273
4
freqtrade/vendor/qtpylib/indicators.py
vendored
4
freqtrade/vendor/qtpylib/indicators.py
vendored
@ -113,11 +113,15 @@ def heikinashi(bars):
|
||||
bars['low'] + bars['close']) / 4
|
||||
|
||||
# ha open
|
||||
idx = bars.index.name
|
||||
bars.reset_index(inplace=True)
|
||||
for i in range(0, len(bars)):
|
||||
bars.at[i, 'ha_open'] = (
|
||||
(bars.at[0, 'open'] if i == 0 else bars.at[i - 1, 'ha_open']) +
|
||||
(bars.at[0, 'close'] if i == 0 else bars.at[i - 1, 'ha_close'])
|
||||
) / 2
|
||||
if idx:
|
||||
bars.set_index(idx, inplace=True)
|
||||
|
||||
bars['ha_high'] = bars.loc[:, ['high', 'ha_open', 'ha_close']].max(axis=1)
|
||||
bars['ha_low'] = bars.loc[:, ['low', 'ha_open', 'ha_close']].min(axis=1)
|
||||
|
Loading…
Reference in New Issue
Block a user