kylejusticemagnuson / pyti

Python library of various financial technical indicators
MIT License
646 stars 169 forks source link

ATR differences #35

Closed 0zd3m1r closed 2 years ago

0zd3m1r commented 2 years ago

The ATR indicator implementation in PYTI gives results that differ from all 4 variants (RMA/SMA/EMA/WMA) of Tradingview's ATR.

I know last commit to this lib was done 2 years ago, but maybe someone knows the solution to this problem.

0zd3m1r commented 2 years ago

I formulated it and got the correct result. who can't fix the problem:

high_low = high_array - low_array high_close = abs(high_array - close_array) low_close = abs(low_array-close_array) dfhl = (pandas.DataFrame(high_low)) dfhc = (pandas.DataFrame(high_close)) dflc = (pandas.DataFrame(low_close)) ranges = pandas.concat([dfhl, dfhc, dflc], axis=1) t_range = np.max(ranges, axis=1) atrSMA = t_range.rolling(14).mean() atrRMA = t_range.ewm(alpha=1/14).mean()