Momentum
Momentum indicators measure the speed and strength of price movements, helping identify overbought/oversold conditions and potential trend reversals.
Import Statement
from openalgo import taAvailable Momentum Indicators
Relative Strength Index (RSI)
RSI is a momentum oscillator that measures the speed and magnitude of price changes, oscillating between 0 and 100.
Usage
rsi_result = ta.rsi(data, period=14)Parameters
data (array-like): Price data (typically closing prices)
period (int, default=14): Number of periods for RSI calculation
Returns
array: RSI values (range: 0 to 100) in the same format as input
Example
Moving Average Convergence Divergence (MACD)
MACD is a trend-following momentum indicator showing the relationship between two exponential moving averages.
Usage
Parameters
data (array-like): Price data (typically closing prices)
fast_period (int, default=12): Period for fast EMA
slow_period (int, default=26): Period for slow EMA
signal_period (int, default=9): Period for signal line EMA
Returns
tuple: (macd_line, signal_line, histogram) arrays
Example
Stochastic Oscillator
The Stochastic Oscillator compares a security's closing price to its price range over a given time period.
Usage
Parameters
high (array-like): High prices
low (array-like): Low prices
close (array-like): Closing prices
k_period (int, default=14): Period for %K calculation
d_period (int, default=3): Period for %D calculation (SMA of %K)
Returns
tuple: (k_percent, d_percent) arrays
Example
Commodity Channel Index (CCI)
CCI measures the current price level relative to an average price level over a given period.
Usage
Parameters
high (array-like): High prices
low (array-like): Low prices
close (array-like): Closing prices
period (int, default=20): Number of periods for CCI calculation
Returns
array: CCI values in the same format as input
Example
Williams %R
Williams %R is a momentum indicator that measures overbought and oversold levels on a scale from 0 to -100.
Usage
Parameters
high (array-like): High prices
low (array-like): Low prices
close (array-like): Closing prices
period (int, default=14): Number of periods for Williams %R calculation
Returns
array: Williams %R values (range: 0 to -100) in the same format as input
Example
Balance of Power (BOP)
Balance of Power measures the strength of buyers versus sellers by assessing the ability of each side to drive prices to an extreme level.
Usage
Parameters
open_prices (array-like): Opening prices
high (array-like): High prices
low (array-like): Low prices
close (array-like): Closing prices
Returns
array: BOP values in the same format as input
Example
Elder Ray Index
Elder Ray Index consists of Bull Power and Bear Power, measuring the ability of bulls and bears to drive prices above or below an EMA.
Usage
Parameters
high (array-like): High prices
low (array-like): Low prices
close (array-like): Closing prices
period (int, default=13): Period for EMA calculation
Returns
tuple: (bull_power, bear_power) arrays
Example
Fisher Transform
The Fisher Transform converts prices into a Gaussian normal distribution, making it easier to identify turning points.
Usage
Parameters
high (array-like): High prices
low (array-like): Low prices
length (int, default=9): Length for highest/lowest calculation
Returns
tuple: (fisher, trigger) arrays
Example
Connors RSI (CRSI)
Connors RSI is a composite momentum oscillator consisting of three components: RSI of price, RSI of updown streak, and percent rank of 1-period ROC.
Usage
Parameters
data (array-like): Price data (typically closing prices)
lenrsi (int, default=3): RSI Length (period for price RSI)
lenupdown (int, default=2): UpDown Length (period for streak RSI)
lenroc (int, default=100): ROC Length (period for ROC percent rank)
Returns
array: Connors RSI values in the same format as input
Example
Complete Example: Multiple Momentum Indicators
Signal Interpretation Guide
RSI
> 70: Overbought (potential sell signal)
< 30: Oversold (potential buy signal)
50: Neutral momentum
MACD
MACD > Signal: Bullish momentum
MACD < Signal: Bearish momentum
Histogram > 0: Increasing bullish momentum
Histogram < 0: Increasing bearish momentum
Stochastic
%K > 80: Overbought conditions
%K < 20: Oversold conditions
%K crossing above %D: Bullish signal
%K crossing below %D: Bearish signal
CCI
> +100: Strong uptrend
< -100: Strong downtrend
-100 to +100: Ranging market
Williams %R
> -20: Overbought
< -80: Oversold
Crossing -50: Trend change signal
Performance Tips
Use appropriate periods: Shorter periods for more sensitive signals, longer for smoother trends
Combine indicators: Use multiple momentum indicators to confirm signals
Market context: Consider overall market trend when interpreting momentum signals
Divergences: Look for divergences between price and momentum indicators
Last updated
Was this helpful?