'issue on pandas_ta adx indicator
when i run this code it's obvious get this error s missing close value.
df['ADX'] = ta.adx(df['High'], df['Low'],length = 14)
df
output:
TypeError Traceback (most recent call last)
<ipython-input-23-1031ca130ef0> in <module>
----> 1 df['ADX'] = ta.adx(df['High'], df['Low'],length = 14)
2 df
TypeError: adx() missing 1 required positional argument: 'close'
now when give closing value and run
df['ADX'] = ta.adx(df['High'], df['Low'],df['Close'],length = 14)
df
output:
`enter code here`ValueError: Wrong number of items passed 3, placement implies 1
if any one know where i am doing wrong please let me know .
this is how i am gettinf dataframe
df = get_history(symbol = "BTCUSDT", interval = "1d", start = timestamp)
df
Solution 1:[1]
The ADX indicator generates three dataframe columns, which is why there is this exception. Do this like this:
a = ta.adx(df['High'], df['Low'], df['Close'], length = 14)
df = df.join(a)
df
you will get three columns with data
(ADX_14 DMP_14 DMN_14)
and you can remove unnecessary columns with the drop
function
Solution 2:[2]
Try this:
import talib
real = talib.ADX(df['High'], df['Low'], df['Close'], timeperiod=14)
print(real)
What library do you use to calculate the indicator?
If it doesn't work out, show how you get the data and from where on "BTCUSDT"?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Banana |
Solution 2 |