A Trading Strategy Using a Combination of Technical Indicators

How to Code a Trading Strategy Using the Cyclical Indicator and Moving Averages

Sofien Kaabar, CFA
5 min readJun 11, 2022


Indicators are there to help you trade through guidance of historical price action. This article discusses a new strategy that gives out bullish signals using simple calculations and filtered by moving averages.

I have released a new book called “Contrarian Trading Strategies in Python”. It features a lot of advanced contrarian indicators and strategies with a GitHub page dedicated to the continuously updated code. If you are interested, you could buy the PDF version directly through a PayPal payment of 9.99 EUR.

Please include your email in the note before paying so that you receive it on the right address. Also, once you receive it, make sure to download it through google drive.

Creating K’s Cyclical Indicator

The indicator has been created mostly to search for bullish signals and is based on simple comparisons between the OHLC values. It is a hybrid indicator in the sense that it can be used in a bullish trend or in a sideways market, however, I absolutely recommend that you do not use it in a bearish trend.

To create K’s cyclical indicator, follow these steps:

  • Whenever the current close price is greater than the current open price, a value of 1 is stored.
  • Whenever the current high price is greater than the previous high price, a value of 1 is stored.
  • Whenever the current high price is greater than the close price from 2 periods ago, a value of 1 is stored.
  • Sum the previous results with their respective numbers using a lookback period of 13 and divide by 13 so that you get a percentage of the 1’s relative to the total (which is 1’s and 0's)
  • Multiply the results of the previous step together which should give you a weighted percentage reading.



Sofien Kaabar, CFA

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