The Bull & Bear Power

Creating and the Bull & Bear Power Index in Python

Sofien Kaabar, CFA
4 min readOct 21, 2022

--

There are many methods to measure who is in control, bulls or bears, and among those methods is Elder Ray’s bull bear power Indicator where it uses simple formulas to approximate this implied technical strength. In this article, we will code the indicator and then judge it from an objective point of view.

It is finally out! My newest book with O’Reilly Media on candlestick pattern recognition is now available on Amazon! The book features a huge number of classic and modern candlestick patterns as it dwelves into the realm of technical analysis with different trading strategies. The book comes with its own GitHub and is dynamic in nature as it is continuously updated and questions are answered on the O’Reilly platform.

Creating the Bull & Bear Power Index Step-by-Step

The Elder Ray Index measures the amount of buying and selling pressure and is composed of two histograms where one is called the Bull Power and the other the Bear Power. The lines are calculated following these formulas:

The EMA variable refers to the exponential moving average which is a type of a moving average that places more weight on recent values. The exponential moving average can be calculated using this below function:

def adder(data, times):

for i in range(1, times + 1):

new = np.zeros((len(data), 1), dtype = float)

data = np.append(data, new, axis = 1)
return datadef deleter(data, index, times):

for i in range(1, times + 1):

data = np.delete(data, index, axis = 1)
return data

def jump(data, jump):

data = data[jump:, ]

return data
def ma(data, lookback, close, where):

data = adder(data, 1)

for i in range(len(data)):

try:

data[i, where] = (data[i …

--

--

Sofien Kaabar, CFA

Top writer in Finance, Investing, Business | Trader & Author