Detecting the Market Regime With Technical Indicators.

Creating & Trading the Gopalakrishnan Range Index in Python.

Sofien Kaabar, CFA
5 min readFeb 20, 2022


Some indicators are specifically used for detecting regimes and volatility as opposed to directional indicators. This article discusses the Gopalakrishnan Range Index which helps us understand the current state.

I have just released a new book after the success of the previous book. It features advanced trend following indicators and strategies with a GitHub page dedicated to the continuously updated code. Also, this book features the original colors after having optimized for printing costs. If you feel that this interests you, feel free to visit the below Amazon link, or if you prefer to buy the PDF version, you could contact me on LinkedIn.

Creating the GRI Index

Also called the GAPO index, the GRI calculates the relative strength between the highs and lows divided by their lookback period.

If in a certain lookback period, the difference between the highest highs and the lowest lows is increasing, then the indicator will rise. If the the index is showing a flat reading, it means that the market has failed to make a higher high and a lower low, therefore, the reading remains stable.

Any time a new high or a new low is made, the indicator’s value will increase to adjust to this, which is why it is a trending indicator.

EURUSD in the first panel with the 14-period GRI in the second panel.
# The function to add a number of columns inside an array
def adder(Data, times):

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

new_col = np.zeros((len(Data), 1), dtype = float)
Data = np.append(Data, new_col, axis = 1)

return Data
# The function to delete a number of columns starting from an index
def deleter(Data, index, times):

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



Sofien Kaabar, CFA

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