TA-Lib / ta-lib-python

Python wrapper for TA-Lib (http://ta-lib.org/).
http://ta-lib.github.io/ta-lib-python
Other
9.49k stars 1.74k forks source link

ATR calculation #498

Open MHermand opened 2 years ago

MHermand commented 2 years ago

Hello :)

I tried to calculate ATR and check the result compare to the built in indicator by using the code below, unfortunately I cannot get the same datas as in the built-in indicator, I used it to build a freqtrade strategy, below is a piece of code :

import talib.abstract as ta

dataframe['atr1'] = ta.ATR(dataframe, timeperiod=10)

dataframe['tr']  = ta.TRANGE(dataframe)
dataframe['atr2'] = ta.MA(dataframe['tr'], timeperiod=10)
dataframe['atr3'] = ta.SMA(dataframe['tr'], timeperiod=10)
dataframe['atr4'] = ta.EMA(dataframe['tr'], timeperiod=10)

Why cannot I get the same datas as the dataframe['atr1'] ? :( Thanks for you help

mrjbq7 commented 2 years ago

Perhaps this is relevant:

https://stackoverflow.com/questions/66322638/is-there-an-error-in-pythons-talib-atr-method