True Range
All functions · nseries package
ATR
func (s Series) ATR(h, l, c Series, n int) Series
ATR is an alias for AvgTrueRange.
It is a simple moving average of TrueRange, not Wilder’s smoothing, and it passes TrueRange through on bars 0 to n-2; the first full average is at bar n-1.
AvgTrueRange
func (s Series) AvgTrueRange(h, l, c Series, n int) Series
AvgTrueRange computes the average true range over n bars: the simple moving average of TrueRange over n bars. During the warm-up (indices below n-1) it passes the true range through unchanged, as Average does, and for n < 1 or n > len(h) it returns the true range unchanged. It is not Wilder’s exponentially smoothed ATR.
The first full average is at bar n-1; bars 0 to n-2 pass TrueRange through, as the simple average does.
TrueRange
func (s Series) TrueRange(h, l, c Series) Series
TrueRange computes the true range of each bar from the highs h, lows l and closes c. Bar 0 has no previous close, so its true range is the bar’s own high minus its low, h[0] - l[0], as in Wilder, TradingView and pandas-ta. From bar 1 it is max(previous close, high) minus min(previous close, low). If h, l and c are not all the same length, the result is an empty series.