Multiple Stochastic Trading Strategy

Creating & Coding the Multiple Stochastic Trading Strategy in Python

Sofien Kaabar, CFA
6 min readOct 28, 2022


The stochastic oscillator is known for its ease of use, simplicity, and ease of integration in complex strategies. This article will present the oscillator as well as a less-known strategy that uses multiple confirmation signals from different stochastic oscillators.

I have 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. If you feel that this interests you, feel free to visit the below Amazon link (which contains a sample), or if you prefer to buy the PDF version, you could check the link at the end of the article.

The Stochastic Oscillator

The first concept to understand with the stochastic oscillator is normalization. This technique allows us to trap values between 0 and 1 (or 0 and 100 if we wish to multiply by 100). The concept revolves around subtracting the minimum value in a certain lookback period from the current value and dividing by the maximum value in the same lookback period minus the minimum value (the same in the nominator).

The stochastic oscillator seeks to find oversold and overbought zones by incorporating the highs and lows using the normalization formula as shown below:

An overbought level is an area where the market is perceived to be extremely bullish and is bound to consolidate. An oversold level is an area where market is perceived to be extremely bearish and is bound to bounce. Hence, the stochastic oscillator is a contrarian indicator that seeks to signal reactions of extreme movements. We will create the below function that calculates the Stochastic on an OHLC data:

def stochastic(Data, lookback, high, low, close, where, genre = 'High-Low'):

# Adding a column
Data = adder(Data, 1)

if genre ==…



Sofien Kaabar, CFA

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