Calculate the Elder Ray Index (Bull Power and Bear Power) for a given price series.

The Elder Ray Index measures buying and selling pressure in the market relative to a trend baseline (an Exponential Moving Average of the closing price). Bull Power captures how far the high extends above the EMA (buying pressure), while Bear Power captures how far the low extends below the EMA (selling pressure).

The formula is as follows:

\[\text{Bull Power} = \text{High} - \operatorname{EMA}(\text{Close},\; \text{window})\] \[\text{Bear Power} = \text{Low} - \operatorname{EMA}(\text{Close},\; \text{window})\]

Also known as: Elder Ray, Bull Power, Bear Power.

No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Elder Ray Index for you. Just ask in plain English.

Calculate the Elder Ray Index in Python

The Elder Ray Index is available in the Technicals module of the open-source Finance Toolkit. Install it with:

pip install financetoolkit -U

Then call get_elder_ray_index as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(tickers=["AAPL", "MSFT"])

toolkit.technicals.get_elder_ray_index().xs("AAPL", level=1, axis="columns")

Which returns:

Date Bear Power Bull Power
2022-12-16 -6.837 -2.917
2022-12-19 -7.8589 -3.9789
2022-12-20 -8.089 -4.729
2022-12-21 -4.6449 -0.5849
2022-12-22 -6.1399 -1.8799
2022-12-23 -5.9285 -3.1485
2022-12-27 -5.8444 -3.1544
2022-12-28 -7.2695 -2.1095
2022-12-29 -4.6924 -1.9424
2022-12-30 -4.4235 -1.9035

Parameters

get_elder_ray_index accepts the following parameters:

  • period (str, optional): The time period to consider for historical data. Can be “daily”, “weekly”, “quarterly”, or “yearly”. Defaults to “daily”.
  • close_column (str, optional): The column name for closing prices in the historical data. Defaults to “Adj Close”.
  • window (int, optional): The number of periods for the EMA used as the trend baseline. Defaults to 13, as originally proposed by Elder.
  • rounding (int | None, optional): The number of decimals to round the results to. Defaults to 4.
  • growth (bool, optional): Whether to calculate the growth of the Bull and Bear Power. Defaults to False.
  • lag (int | list[int], optional): The lag to use for the growth calculation.
  • standardize (bool, optional): Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. Defaults to 1.

The Technicals module page introduces the module, and the sidebar lists all of its functions.

Share