Momentum

Momentum Indicators — Oscillators measuring speed and change of price movements.

Functions

RSI — Relative Strength Index MOM — Momentum ROC — Rate of Change: ((price/prevPrice)-1)*100 ROCP — Rate of Change Percentage: (price-prevPrice)/prevPrice ROCR — Rate of Change Ratio: price/prevPrice ROCR100 — Rate of Change Ratio 100 scale: (price/prevPrice)*100 WILLR — Williams’ %R AROON — Aroon (returns aroon_down, aroon_up) AROONOSC — Aroon Oscillator CCI — Commodity Channel Index MFI — Money Flow Index BOP — Balance Of Power STOCHF — Stochastic Fast STOCH — Stochastic STOCHRSI — Stochastic Relative Strength Index APO — Absolute Price Oscillator PPO — Percentage Price Oscillator CMO — Chande Momentum Oscillator PLUS_DM — Plus Directional Movement MINUS_DM — Minus Directional Movement PLUS_DI — Plus Directional Indicator MINUS_DI — Minus Directional Indicator DX — Directional Movement Index ADX — Average Directional Movement Index ADXR — Average Directional Movement Index Rating DMI — Directional Movement Index (+DI, -DI, ADX) TRIX — 1-day Rate-Of-Change of Triple Smooth EMA ULTOSC — Ultimate Oscillator TRANGE — True Range (also in volatility) ELDER_RAY — Elder Ray bull / bear power FISHER — Ehlers Fisher Transform CRSI — Connors RSI

ferro_ta.momentum.ADX(high, low, close, timeperiod=14)[source]

Average Directional Movement Index.

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

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

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

  • timeperiod (int, optional) – Smoothing period (default 14).

Returns:

Array of ADX values (0–100).

Return type:

numpy.ndarray

ferro_ta.momentum.ADXR(high, low, close, timeperiod=14)[source]

Average Directional Movement Index Rating.

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

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

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

  • timeperiod (int, optional) – Smoothing period (default 14).

Returns:

Array of ADXR values (0–100).

Return type:

numpy.ndarray

ferro_ta.momentum.APO(close, fastperiod=12, slowperiod=26, matype=1)[source]

Absolute Price Oscillator.

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

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

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

  • matype (int, optional) –

    Moving average type for both legs. Defaults to 1 (EMA) rather than TA-Lib’s 0 (SMA), because this function has always computed the EMA form; pass 0 for TA-Lib’s SMA form (default 1):

    • 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)

    • 8 = T3 (Tillson; exact alias of 7)

    Values 0-6 and 8 match TA-Lib’s numbering, but 7 is T3 here where TA-Lib’s 7 is MAMA. MAMA is not reachable through any matype value – call ferro_ta.MAMA() directly.

Returns:

Array of APO values; leading entries are NaN for the slow leg’s lookback (which depends on matype).

Return type:

numpy.ndarray

ferro_ta.momentum.AROON(high, low, timeperiod=14)[source]

Aroon.

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

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

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

Returns:

(aroondown, aroonup) — two arrays of equal length. Leading timeperiod entries are NaN.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

ferro_ta.momentum.AROONOSC(high, low, timeperiod=14)[source]

Aroon Oscillator.

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 AROONOSC values; leading timeperiod entries are NaN.

Return type:

numpy.ndarray

ferro_ta.momentum.BOP(open, high, low, close)[source]

Balance Of Power.

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

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

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

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

Returns:

Array of BOP values (-1 to 1).

Return type:

numpy.ndarray

ferro_ta.momentum.CCI(high, low, close, timeperiod=14)[source]

Commodity Channel Index.

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

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

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

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

Returns:

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

Return type:

numpy.ndarray

ferro_ta.momentum.CMO(close, timeperiod=14)[source]

Chande Momentum Oscillator.

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

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

Returns:

Array of CMO values (-100 to 100); leading timeperiod entries are NaN.

Return type:

numpy.ndarray

ferro_ta.momentum.CRSI(close, timeperiod=3, streakperiod=2, rankperiod=100)[source]

Connors RSI — average of price RSI, streak RSI, and ROC percent rank.

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

  • timeperiod (int, optional) – RSI period of close (default 3).

  • streakperiod (int, optional) – RSI period of the up/down streak (default 2).

  • rankperiod (int, optional) – Percent-rank lookback of 1-bar ROC (default 100).

Returns:

Array of Connors RSI values (0–100).

Return type:

numpy.ndarray

ferro_ta.momentum.DMI(high, low, close, timeperiod=14)[source]

Directional Movement Index — (PLUS_DI, MINUS_DI, ADX) in one pass.

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

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

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

  • timeperiod (int, optional) – Wilder smoothing period (default 14).

Returns:

plus_di, minus_di, adx – The three ADX-family series, identical to calling PLUS_DI, MINUS_DI, and ADX separately.

Return type:

numpy.ndarray

ferro_ta.momentum.DX(high, low, close, timeperiod=14)[source]

Directional Movement Index.

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

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

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

  • timeperiod (int, optional) – Smoothing period (default 14).

Returns:

Array of DX values (0–100).

Return type:

numpy.ndarray

ferro_ta.momentum.ELDER_RAY(high, low, close, timeperiod=13)[source]

Elder Ray Index — bull power and bear power versus EMA(close).

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

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

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

  • timeperiod (int, optional) – EMA period (default 13).

Returns:

(bull_power, bear_power). Leading timeperiod - 1 entries are NaN.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

ferro_ta.momentum.FISHER(high, low, timeperiod=9)[source]

Ehlers Fisher Transform of median price.

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

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

  • timeperiod (int, optional) – Highest / lowest lookback (default 9).

Returns:

(fisher, signal) where signal is the previous Fisher value. Leading timeperiod - 1 Fisher entries are NaN.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

ferro_ta.momentum.MFI(high, low, close, volume, timeperiod=14)[source]

Money Flow Index.

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

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

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

  • volume (array-like) – Sequence of volume values.

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

Returns:

Array of MFI values (0–100); leading timeperiod entries are NaN.

Return type:

numpy.ndarray

ferro_ta.momentum.MINUS_DI(high, low, close, timeperiod=14)[source]

Minus Directional Indicator.

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

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

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

  • timeperiod (int, optional) – Smoothing period (default 14).

Returns:

Array of -DI values.

Return type:

numpy.ndarray

ferro_ta.momentum.MINUS_DM(high, low, timeperiod=14)[source]

Minus Directional Movement.

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

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

  • timeperiod (int, optional) – Smoothing period (default 14).

Returns:

Array of -DM values.

Return type:

numpy.ndarray

ferro_ta.momentum.MOM(close, timeperiod=10)[source]

Momentum.

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

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

Returns:

Array of MOM values; leading timeperiod entries are NaN.

Return type:

numpy.ndarray

ferro_ta.momentum.PLUS_DI(high, low, close, timeperiod=14)[source]

Plus Directional Indicator.

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

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

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

  • timeperiod (int, optional) – Smoothing period (default 14).

Returns:

Array of +DI values.

Return type:

numpy.ndarray

ferro_ta.momentum.PLUS_DM(high, low, timeperiod=14)[source]

Plus Directional Movement.

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

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

  • timeperiod (int, optional) – Smoothing period (default 14).

Returns:

Array of +DM values.

Return type:

numpy.ndarray

ferro_ta.momentum.PPO(close, fastperiod=12, slowperiod=26, signalperiod=9, matype=1)[source]

Percentage Price Oscillator.

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

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

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

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

  • matype (int, optional) –

    Moving average type for the fast and slow legs. Defaults to 1 (EMA) rather than TA-Lib’s 0 (SMA), because this function has always computed the EMA form; pass 0 for TA-Lib’s SMA form (default 1):

    • 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)

    • 8 = T3 (Tillson; exact alias of 7)

    Values 0-6 and 8 match TA-Lib’s numbering, but 7 is T3 here where TA-Lib’s 7 is MAMA. MAMA is not reachable through any matype value – call ferro_ta.MAMA() directly.

Returns:

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

Return type:

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

ferro_ta.momentum.ROC(close, timeperiod=10)[source]

Rate of Change: ((price/prevPrice)-1)*100.

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

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

Returns:

Array of ROC values; leading timeperiod entries are NaN.

Return type:

numpy.ndarray

ferro_ta.momentum.ROCP(close, timeperiod=10)[source]

Rate of Change Percentage: (price-prevPrice)/prevPrice.

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

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

Returns:

Array of ROCP values; leading timeperiod entries are NaN.

Return type:

numpy.ndarray

ferro_ta.momentum.ROCR(close, timeperiod=10)[source]

Rate of Change Ratio: price/prevPrice.

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

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

Returns:

Array of ROCR values; leading timeperiod entries are NaN.

Return type:

numpy.ndarray

ferro_ta.momentum.ROCR100(close, timeperiod=10)[source]

Rate of Change Ratio 100 scale: (price/prevPrice)*100.

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

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

Returns:

Array of ROCR100 values; leading timeperiod entries are NaN.

Return type:

numpy.ndarray

ferro_ta.momentum.RSI(close, timeperiod=14, *, nan_policy='propagate')[source]

Relative Strength Index.

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

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

  • nan_policy ({"propagate", "skip"}, optional) – "propagate" (default, TA-Lib semantics): a NaN input poisons every later value. "skip": rows with a non-finite input are dropped, the indicator runs on the remaining rows, and NaN is written back at the dropped rows (matches the streaming classes tick for tick).

Returns:

Array of RSI values (0–100); leading timeperiod entries are NaN.

Return type:

numpy.ndarray

ferro_ta.momentum.STOCH(high, low, close, fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3, slowd_matype=0, *, nan_policy='propagate')[source]

Stochastic.

Parameters follow TA-Lib’s interleaved order: each *_matype comes immediately after the period it types, so a mis-ordered positional call fails the type checker instead of returning a wrong answer.

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

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

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

  • fastk_period (int, optional) – Fast %K period (default 5).

  • slowk_period (int, optional) – Slow %K smoothing period (default 3).

  • slowk_matype (int, optional) –

    Moving average type applied to the slow %K leg (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)

    • 8 = T3 (Tillson; exact alias of 7)

    Values 0-6 and 8 match TA-Lib’s numbering, but 7 is T3 here where TA-Lib’s 7 is MAMA. MAMA is not reachable through any matype value – call ferro_ta.MAMA() directly.

  • slowd_period (int, optional) – Slow %D smoothing period (default 3).

  • slowd_matype (int, optional) –

    Moving average type applied to the slow %D leg (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)

    • 8 = T3 (Tillson; exact alias of 7)

    Values 0-6 and 8 match TA-Lib’s numbering, but 7 is T3 here where TA-Lib’s 7 is MAMA. MAMA is not reachable through any matype value – call ferro_ta.MAMA() directly.

  • nan_policy ({"propagate", "skip"}, optional) – "propagate" (default, TA-Lib semantics): a NaN input poisons every later value. "skip": rows with a non-finite input are dropped, the indicator runs on the remaining rows, and NaN is written back at the dropped rows (matches the streaming classes tick for tick).

Returns:

(slowk, slowd) — two arrays of equal length.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

ferro_ta.momentum.STOCHF(high, low, close, fastk_period=5, fastd_period=3, fastd_matype=0)[source]

Stochastic Fast.

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

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

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

  • fastk_period (int, optional) – %K period (default 5).

  • fastd_period (int, optional) – %D smoothing period (default 3).

  • fastd_matype (int, optional) –

    Moving average type applied to the %D leg (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)

    • 8 = T3 (Tillson; exact alias of 7)

    Values 0-6 and 8 match TA-Lib’s numbering, but 7 is T3 here where TA-Lib’s 7 is MAMA. MAMA is not reachable through any matype value – call ferro_ta.MAMA() directly.

Returns:

(fastk, fastd) — two arrays of equal length.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

ferro_ta.momentum.STOCHRSI(close, timeperiod=14, fastk_period=5, fastd_period=3, fastd_matype=0)[source]

Stochastic Relative Strength Index.

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

  • timeperiod (int, optional) – RSI period (default 14).

  • fastk_period (int, optional) – Stochastic %K period (default 5).

  • fastd_period (int, optional) – Stochastic %D smoothing period (default 3).

  • fastd_matype (int, optional) –

    Moving average type applied to the %D leg (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)

    • 8 = T3 (Tillson; exact alias of 7)

    Values 0-6 and 8 match TA-Lib’s numbering, but 7 is T3 here where TA-Lib’s 7 is MAMA. MAMA is not reachable through any matype value – call ferro_ta.MAMA() directly.

Returns:

(fastk, fastd) — two arrays of equal length.

Return type:

tuple[numpy.ndarray, numpy.ndarray]

ferro_ta.momentum.TRANGE(high, low, close)[source]

True Range.

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

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

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

Returns:

Array of True Range values.

Return type:

numpy.ndarray

ferro_ta.momentum.TRIX(close, timeperiod=30)[source]

1-day Rate-Of-Change of a Triple Smooth EMA.

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

  • timeperiod (int, optional) – EMA period (default 30).

Returns:

Array of TRIX values.

Return type:

numpy.ndarray

ferro_ta.momentum.ULTOSC(high, low, close, timeperiod1=7, timeperiod2=14, timeperiod3=28)[source]

Ultimate Oscillator.

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

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

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

  • timeperiod1 (int, optional) – First period (default 7).

  • timeperiod2 (int, optional) – Second period (default 14).

  • timeperiod3 (int, optional) – Third period (default 28).

Returns:

Array of ULTOSC values (0–100).

Return type:

numpy.ndarray

ferro_ta.momentum.WILLR(high, low, close, timeperiod=14)[source]

Williams’ %R.

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

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

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

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

Returns:

Array of WILLR values (-100 to 0); leading timeperiod - 1 entries are NaN.

Return type:

numpy.ndarray