Creating the Swing Indicator in TradingView

How to Create & Visualize the Swing Indicator in TradingView

Sofien Kaabar, CFA

--

Momentum can be faded in many ways when we have enough elements to suggest that exhaustion may happen. This can be done through divergence analysis, oversold/overbought levels, and timing indicators. In this article, we will create an indicator that can be used both for discretionary and systematic trading, the swing indicator which takes into account highs and lows to determine empirical mean-reversion levels.

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.

The Basics of the Swing Indicator

The swing indicator is based on finding patterns where the trend starts to weaken when approaching a certain threshold. This can be measured by the Momentum Gauge calculation seen below. The first calculation has the following score that will be later summed up:

  • 0 if the current high is less than the previous high and the current close is less than the current open price.
  • 1 if either the current high is greater than the previous high or the current close is greater than the current open price.
  • 2 if both current high is greater than the previous high and the current close is greater than the current open price.
  • 0 if the current low is greater than the previous low and the current close is greater than the current open price.
  • 1 if either the current low is lower than the previous low or the current close is lower than the current open price.
  • 2 if both current low is lower than the previous low and the current close is lower than the current open price.

--

--