How to calculate the average true range (ATR) by only using numpy? I prefer the fastest way possible.
Atr calculation:
Pandas & Numpy:
import numpy as np
import pandas as pd
high_low = data['High'] - data['Low']
high_close = np.abs(data['High'] - data['Close'].shift())
low_close = np.abs(data['Low'] - data['Close'].shift())
ranges = pd.concat([high_low, high_close, low_close], axis=1)
true_range = np.max(ranges, axis=1)
atr = true_range.rolling(14).sum()/14