def ATR(df, n = 20): tr = TR(df) ts_atr = pd.ewma(tr, span=n, min_periods = n-1, adjust = False) ts_atr.name = 'ATR'+str(n) return ts_atr