Skip to content

SimpleMovingAverage


class backtide.indicators.SimpleMovingAverage(period=14)

Simple Moving Average (SMA).

The arithmetic mean of the last n closing prices. Used to smooth short-term fluctuations and identify the direction of a trend. Useful for trend identification, support/resistance levels, and crossover strategies (e.g., golden cross / death cross).

Formula:

\[SMA_t = \frac{1}{n} \sum_{i=0}^{n-1} C_{t-i}\]

where \(C_t\) is the closing price at time \(t\) and \(n\) is the period. 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

BollingerBands

Bollinger Bands (BB).

ExponentialMovingAverage

Exponential Moving Average (EMA).

WeightedMovingAverage

Weighted Moving Average (WMA).


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.