heikinashi loop optimized; reset_index moved to tests
This commit is contained in:
parent
1ccc25b486
commit
45e5867736
12
freqtrade/vendor/qtpylib/indicators.py
vendored
12
freqtrade/vendor/qtpylib/indicators.py
vendored
@ -113,15 +113,9 @@ def heikinashi(bars):
|
|||||||
bars['low'] + bars['close']) / 4
|
bars['low'] + bars['close']) / 4
|
||||||
|
|
||||||
# ha open
|
# ha open
|
||||||
idx = bars.index.name
|
bars.at[0, 'ha_open'] = (bars.at[0, 'open'] + bars.at[0, 'close']) / 2
|
||||||
bars.reset_index(inplace=True)
|
for i in range(1, len(bars)):
|
||||||
for i in range(0, len(bars)):
|
bars.at[i, 'ha_open'] = (bars.at[i - 1, 'ha_open'] + bars.at[i - 1, 'ha_close']) / 2
|
||||||
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_high'] = bars.loc[:, ['high', 'ha_open', 'ha_close']].max(axis=1)
|
||||||
bars['ha_low'] = bars.loc[:, ['low', 'ha_open', 'ha_close']].min(axis=1)
|
bars['ha_low'] = bars.loc[:, ['low', 'ha_open', 'ha_close']].min(axis=1)
|
||||||
|
Loading…
Reference in New Issue
Block a user