The Reversal Indicator — Coding in Python.

Coding the Rob Booker Reversal Indicator in Python.

Sofien Kaabar, CFA


Some less-known indicator actually function pretty well. Among those indicator is Rob Booker’s Reversal Indicator which uses a special combination between the MACD oscillator and the Stochastic oscillator. This article discusses creating the indicator in Python. All credits go to Rob Booker.

I have just released a new book after the success of my previous one “Trend Following Strategies in Python”. It features advanced contrarian 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 check the link at the end of the article.

The MACD Oscillator

The MACD is probably the second most known oscillator after the RSI. One that is heavily followed by traders. It stands for Moving Average Convergence Divergence and it is used mainly for divergences and flips. Many people also consider it a trend-following indicator but others use graphical analysis on it to find reversal points, making the MACD a versatile indicator.

USDCHF in the first panel with the MACD in the second panel.

How is the MACD calculated? It is the difference between the 26-period Exponential Moving Average applied to the closing price and the 12-period Exponential Moving Average also applied to the closing price. The value found after taking the difference is called the MACD line. The 9-period Exponential Moving Average of that calculation is called the MACD signal.

EURUSD in the first panel with the MACD in the second panel.
# The function to add