Overlap Studies

Overlap Studies — Moving averages and bands that overlay directly on the price chart.

Functions

SMA — Simple Moving Average EMA — Exponential Moving Average WMA — Weighted Moving Average DEMA — Double Exponential Moving Average TEMA — Triple Exponential Moving Average TRIMA — Triangular Moving Average KAMA — Kaufman Adaptive Moving Average T3 — Triple Exponential Moving Average (Tillson T3) BBANDS — Bollinger Bands MACD — Moving Average Convergence/Divergence MACDFIX — MACD with fixed 12/26 periods MACDEXT — MACD with controllable MA types SAR — Parabolic SAR SAREXT — Parabolic SAR Extended MA — Generic Moving Average (dispatches on matype) MAVP — Moving Average with Variable Period MAMA — MESA Adaptive Moving Average MIDPOINT — MidPoint over period MIDPRICE — MidPrice over period (High/Low)

ferro_ta.overlap.BBANDS(close, timeperiod=5, nbdevup=2.0, nbdevdn=2.0)[source]

Bollinger Bands.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Moving average window (default 5).

  • nbdevup (float, optional) – Number of standard deviations above the middle band (default 2.0).

  • nbdevdn (float, optional) – Number of standard deviations below the middle band (default 2.0).

Returns:

(upperband, middleband, lowerband) — three arrays of equal length. Leading timeperiod - 1 entries are NaN.

Return type:

tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

ferro_ta.overlap.DEMA(close, timeperiod=30)[source]

Double Exponential Moving Average.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Number of periods (default 30).

Returns:

Array of DEMA values; leading 2 * (timeperiod - 1) entries are NaN.

Return type:

numpy.ndarray

ferro_ta.overlap.EMA(close, timeperiod=30)[source]

Exponential Moving Average.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Number of periods (default 30).

Returns:

Array of EMA values; leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray

ferro_ta.overlap.KAMA(close, timeperiod=30)[source]

Kaufman Adaptive Moving Average.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Efficiency Ratio lookback period (default 30).

Returns:

Array of KAMA values; leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray

ferro_ta.overlap.MA(close, timeperiod=30, matype=0)[source]

Generic Moving Average.

Dispatches to the appropriate MA implementation based on matype.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Number of periods (default 30).

  • matype (int, optional) –

    Moving average type (default 0):

    • 0 = SMA (Simple)

    • 1 = EMA (Exponential)

    • 2 = WMA (Weighted)

    • 3 = DEMA (Double EMA)

    • 4 = TEMA (Triple EMA)

    • 5 = TRIMA (Triangular)

    • 6 = KAMA (Kaufman Adaptive)

    • 7 = T3 (Tillson)

Returns:

Array of MA values.

Return type:

numpy.ndarray

ferro_ta.overlap.MACD(close, fastperiod=12, slowperiod=26, signalperiod=9)[source]

Moving Average Convergence/Divergence.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • fastperiod (int, optional) – Fast EMA period (default 12).

  • slowperiod (int, optional) – Slow EMA period (default 26).

  • signalperiod (int, optional) – Signal EMA period (default 9).

Returns:

(macd, signal, histogram) — three arrays of equal length. Leading values that cannot be computed are NaN.

Return type:

tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

ferro_ta.overlap.MACDEXT(close, fastperiod=12, fastmatype=1, slowperiod=26, slowmatype=1, signalperiod=9, signalmatype=1)[source]

MACD with Controllable MA Types.

Like MACD() but allows specifying the moving average type for each of the fast, slow, and signal lines independently.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • fastperiod (int, optional) – Fast MA period (default 12).

  • fastmatype (int, optional) – MA type for the fast line (default 1 = EMA).

  • slowperiod (int, optional) – Slow MA period (default 26).

  • slowmatype (int, optional) – MA type for the slow line (default 1 = EMA).

  • signalperiod (int, optional) – Signal MA period (default 9).

  • signalmatype (int, optional) – MA type for the signal line (default 1 = EMA).

  • codes (MA type)

Returns:

(macd, signal, histogram) — three arrays of equal length.

Return type:

tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

ferro_ta.overlap.MACDFIX(close, signalperiod=9)[source]

Moving Average Convergence/Divergence Fix 12/26.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • signalperiod (int, optional) – Signal EMA period (default 9).

Returns:

(macd, signal, histogram) — three arrays of equal length.

Return type:

tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray]

ferro_ta.overlap.MAMA(close, fastlimit=0.5, slowlimit=0.05)[source]

MESA Adaptive Moving Average.

Returns the MAMA and FAMA (Following Adaptive MA) lines. The adaptive alpha is derived from the rate of phase change of the Hilbert Transform.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • fastlimit (float, optional) – Upper bound on the adaptive smoothing factor (default 0.5).

  • slowlimit (float, optional) – Lower bound on the adaptive smoothing factor (default 0.05).

Returns:

(mama, fama) — two arrays; first 32 entries are NaN.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

ferro_ta.overlap.MAVP(close, periods, minperiod=2, maxperiod=30)[source]

Moving Average with Variable Period.

Computes a simple moving average at each bar using the period given by the corresponding element of periods. Periods are clamped to [minperiod, maxperiod].

Parameters:
  • close (array-like) – Sequence of closing prices.

  • periods (array-like) – Sequence of period values (one per bar, same length as close).

  • minperiod (int, optional) – Minimum allowed period (default 2).

  • maxperiod (int, optional) – Maximum allowed period (default 30).

Returns:

Array of variable-period MA values.

Return type:

numpy.ndarray

ferro_ta.overlap.MIDPOINT(close, timeperiod=14)[source]

MidPoint over period — (max + min) / 2 of close.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Number of periods (default 14).

Returns:

Array of MIDPOINT values; leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray

ferro_ta.overlap.MIDPRICE(high, low, timeperiod=14)[source]

MidPrice over period — (highest high + lowest low) / 2.

Parameters:
  • high (array-like) – Sequence of high prices.

  • low (array-like) – Sequence of low prices.

  • timeperiod (int, optional) – Number of periods (default 14).

Returns:

Array of MIDPRICE values; leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray

ferro_ta.overlap.SAR(high, low, acceleration=0.02, maximum=0.2)[source]

Parabolic SAR.

Parameters:
  • high (array-like) – Sequence of high prices.

  • low (array-like) – Sequence of low prices.

  • acceleration (float, optional) – Acceleration factor step (default 0.02).

  • maximum (float, optional) – Maximum acceleration factor (default 0.2).

Returns:

Array of SAR values; first entry is NaN.

Return type:

numpy.ndarray

ferro_ta.overlap.SAREXT(high, low, startvalue=0.0, offsetonreverse=0.0, accelerationinitlong=0.02, accelerationlong=0.02, accelerationmaxlong=0.2, accelerationinitshort=0.02, accelerationshort=0.02, accelerationmaxshort=0.2)[source]

Parabolic SAR Extended.

An extended version of the Parabolic SAR that allows independent acceleration parameters for long and short positions, plus an optional fixed start value and a gap-on-reverse offset.

Parameters:
  • high (array-like) – Sequence of high prices.

  • low (array-like) – Sequence of low prices.

  • startvalue (float, optional) – Fixed initial SAR value (0 = auto-detect, default 0.0).

  • offsetonreverse (float, optional) – Multiplier applied to the SAR on trend reversal (default 0.0).

  • accelerationinitlong (float, optional) – Initial acceleration factor for long positions (default 0.02).

  • accelerationlong (float, optional) – Acceleration step for long positions (default 0.02).

  • accelerationmaxlong (float, optional) – Maximum acceleration for long positions (default 0.2).

  • accelerationinitshort (float, optional) – Initial acceleration factor for short positions (default 0.02).

  • accelerationshort (float, optional) – Acceleration step for short positions (default 0.02).

  • accelerationmaxshort (float, optional) – Maximum acceleration for short positions (default 0.2).

Returns:

Array of SAREXT values; first entry is NaN.

Return type:

numpy.ndarray

ferro_ta.overlap.SMA(close, timeperiod=30)[source]

Simple Moving Average.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Number of periods (default 30).

Returns:

Array of SMA values; leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray

ferro_ta.overlap.T3(close, timeperiod=5, vfactor=0.7)[source]

Triple Exponential Moving Average (Tillson T3).

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Number of periods (default 5).

  • vfactor (float, optional) – Volume factor (default 0.7).

Returns:

Array of T3 values.

Return type:

numpy.ndarray

ferro_ta.overlap.TEMA(close, timeperiod=30)[source]

Triple Exponential Moving Average.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Number of periods (default 30).

Returns:

Array of TEMA values; leading 3 * (timeperiod - 1) entries are NaN.

Return type:

numpy.ndarray

ferro_ta.overlap.TRIMA(close, timeperiod=30)[source]

Triangular Moving Average.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Number of periods (default 30).

Returns:

Array of TRIMA values; leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray

ferro_ta.overlap.WMA(close, timeperiod=30)[source]

Weighted Moving Average.

Parameters:
  • close (array-like) – Sequence of closing prices.

  • timeperiod (int, optional) – Number of periods (default 30).

Returns:

Array of WMA values; leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray