Skip to content

MovingAverageConvergenceDivergence


class backtide.indicators.MovingAverageConvergenceDivergence(fast_period=12, slow_period=26, signal_period=9)

Moving Average Convergence Divergence (MACD).

A trend-following momentum indicator that shows the relationship between two EMAs. The MACD line is the difference between a fast and slow EMA; the signal line is an EMA of the MACD line itself. Useful for trend direction and momentum, signal line crossovers for entry/exit timing, and histogram divergence analysis.

Formula:

\[ \begin{aligned} MACD_t &= EMA_{fast}(C_t) - EMA_{slow}(C_t) \\\\ Signal_t &= EMA_{signal}(MACD_t) \end{aligned} \]

Read more on Wikipedia.

Parameters

fast_period : int, default=12

Fast EMA period.

slow_period : int, default=26
Slow EMA period.

signal_period : int, default=9
Signal line EMA period.

Attributes

acronym : str

Short ticker-style acronym.

name : str
Human-readable indicator name.


See Also

AverageDirectionalIndex

Average Directional Index (ADX).

ExponentialMovingAverage

Exponential Moving Average (EMA).

RelativeStrengthIndex

Relative Strength Index (RSI).


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.