Open CrossfireX opened 4 years ago
Hi @CrossfireX ,
This is a warning, not an error. You can use ADX and the results will be right.
Anyway, I will try to solve!
Thank you.
True, the D+ and D- worked correctly, now the trend adx is working too.
same issue with ADX
that's really annoying. Has anybody found a workaround to eliminate that while debugging in vscode?
Hi all,
Due to some reason _trs series is longer by 1 count. We can make the following edit in '/lib/site-packages/ta/trend.py'
line # 760 - 788
`def adx(self) -> pd.Series:
dip = np.zeros(len(self._trs)-1)
for i in range(len(self._trs)-1):
dip[i] = 100 * (self._dip[i] / self._trs[i])
din = np.zeros(len(self._trs)-1)
for i in range(len(self._trs)-1):
din[i] = 100 * (self._din[i] / self._trs[i])
directional_index = 100 * np.abs((dip - din) / (dip + din))
adx_series = np.zeros(len(self._trs))
adx_series[self._window] = directional_index[0 : self._window].mean()
for i in range(self._window + 1, len(adx_series)):
adx_series[i] = (
(adx_series[i - 1] * (self._window - 1)) + directional_index[i - 1]
) / float(self._window)
adx_series = np.concatenate((self._trs_initial, adx_series), axis=0)
adx_series = pd.Series(data=adx_series, index=self._close.index)
adx_series = self._check_fillna(adx_series, value=20)
return pd.Series(adx_series, name="adx")`
I've simply reduced the series dip and din by 1, and running the loop also -1 times.
Informankur's fix solved it for me. I still get the same adx output. Warning is gone :D
same error for me
Running the "visualize_features.ipynb" example gets me this warning:
/home/vant/projects/python/ta/env-ta/lib/python3.7/site-packages/ta/trend.py:468: RuntimeWarning: invalid value encountered in double_scalars dip[i] = 100 * (self._dip[i]/self._trs[i]) /home/vant/projects/python/ta/env-ta/lib/python3.7/site-packages/ta/trend.py:472: RuntimeWarning: invalid value encountered in double_scalars din[i] = 100 * (self._din[i]/self._trs[i])
Looks like an error at ADX trend indicator. Can you please take a look at it? Thanks and keep up the good work!