Skip to content

AverageTrueRange


class backtide.indicators.AverageTrueRange(period=14)

Average True Range (ATR).

Measures market volatility by calculating the average of the true range over a period. The true range accounts for gaps between sessions. Useful for position sizing, setting stop-loss levels, and comparing volatility across instruments.

Formula:

\[ \begin{aligned} TR_t &= \max(H_t - L_t,\; |H_t - C_{t-1}|,\; |L_t - C_{t-1}|) \\\\ ATR_t &= \frac{1}{n} \sum_{i=0}^{n-1} TR_{t-i} \end{aligned} \]

Read more on Wikipedia.

Parameters

period : int, default=14

Look-back window length.

Attributes

acronym : str

Short ticker-style acronym.

name : str
Human-readable indicator name.


See Also

AverageDirectionalIndex

Average Directional Index (ADX).

BollingerBands

Bollinger Bands (BB).

SimpleMovingAverage

Simple Moving Average (SMA).


Methods

compute Compute the indicator on a dataset.
description Short explanation of what the indicator measures.


method backtide.indicatorscompute(data)

Compute the indicator on a dataset.

Parameters

data : np.ndarray | pd.DataFrame | pl.DataFrame

Historical OHLCV data.

Returns

np.ndarray | pd.Series | pl.Series | pd.DataFrame | pl.DataFrame

The computed values. For multi-output indicators (e.g., upper and lower bounds), return a 2d structure.



method backtide.indicatorsdescription()

Short explanation of what the indicator measures.

Returns

str

The description.