The Cross Normalization Technical Indicator
Coding and Using the Cross Normalization Indicator for Trading
This article presents a new technical indicator referred to as the Cross Normalization Indicator (CNI) which capitalizes on price normalization to deliver reversal signals. The indicator is discussed and then the code is given in order to replicate it.
For a detailed and thorough collection of contrarian trading strategies, you can check out my book. The book features a huge number of classic and modern techniques as it dwelves into the realm of technical analysis with different trading strategies. The book comes with its own GitHub.
Contrarian Trading Strategies in Python
Amazon.com: Contrarian Trading Strategies in Python: 9798434008075: Kaabar, Sofien: Booksamzn.to
The Concept of Normalization
Normalization is simply a mathematical calculation that allows us to trap the 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 result is a time series that oscillates between 0 and 1 with values close to 1 indicating higher elements and values close to 0 indicating lower elements.
Coding the Cross Normalization Indicator (CNI)
The Cross Normalization Indicator (CNI) is formed out of two price normalization calculations with different lookback periods, then a 5-period moving average is calculated on both. Therefore, to create the CNI, follow these steps:
Normalize the prices using a lookback period of 5 with values that have a normalized value of 1 representing the highest values in the last 5 observations and values that have a normalized value of 0 representing the lowest values in the last 5 observations.
Normalize the prices using a lookback period of 21 with values that have a normalized value of 1 representing the highest values in the last 21 observations and values that have a normalized value of 0 representing the lowest values in the last 21 observations.
Calculate a 5-period simple moving average on the results from step 1 and step 2.
The CNI is used as follows:
Whenever the two CNI’s are close to 0 and the short-term CNI (the one with 5 as a lookback period) surpasses the long-term CNI (the one with 21 as a lookback period), a long signal is generated.
Whenever the two CNI’s are close to 1 and the short-term CNI (the one with 5 as a lookback period) breaks the long-term CNI (the one with 21 as a lookback period), a short signal is generated.
The following Figure shows three short signals:
The following Figure shows one short signal and one long signal:
The code you can use for the CNI is as follows:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sofien-Kaabar
//@version=5
indicator("Cross Normalization Indicator", overlay = false)
lookback_short = input(defval = 5, title = 'Short Lookback')
lookback_long = input(defval = 21, title = 'Long Lookback')
smoothing = input(defval = 5, title = 'Smoothing')
normalized_price_short = (close - ta.lowest(close, lookback_short)) / (ta.highest(close, lookback_short) - ta.lowest(close, lookback_short))
normalized_price_long = (close - ta.lowest(close, lookback_long)) / (ta.highest(close, lookback_long) - ta.lowest(close, lookback_long))
smoothed_short = ta.sma(normalized_price_short, smoothing)
smoothed_long = ta.sma(normalized_price_long, smoothing)
plot(smoothed_short, color = color.green)
plot(smoothed_long)
hline(0)
hline(1)
The following Figure shows a few signals on the CNI. It tends to work well in ranging markets.
The following Figure shows a few signals on the CNI. It tends to work less well in trending markets.
Summary
To sum up, what I am trying to do is to simply contribute to the world of objective technical analysis which is promoting more transparent techniques and strategies that need to be back-tested before being implemented. This way, technical analysis will get rid of the bad reputation of being subjective and scientifically unfounded.
I recommend you always follow the the below steps whenever you come across a trading technique or strategy:
Have a critical mindset and get rid of any emotions.
Back-test it using real life simulation and conditions.
If you find potential, try optimizing it and running a forward test.
Always include transaction costs and any slippage simulation in your tests.
Always include risk management and position sizing in your tests.
Finally, even after making sure of the above, stay careful and monitor the strategy because market dynamics may shift and make the strategy unprofitable.