Swing documentation

The Swing class uses a mechanical approach to determine the trend of a stock along with breakout and reversal levels.

Python version: >= 3.8

No external dependencies are required.

Pandas and Mplfinance are optional requirements depending on your usage and requirements.

Introduction:

The Swing class works on the same principles of Higher Highs and Higher Lows (in an uptrend) and Lower Lows and Lower Highs (in a downtrend).

_images/hh_hl.png

Within the class,

  • Higher Highs and Lower Lows are called Swing Point High (SPH) and Swing Point Low (SPL).

  • Higher Lows and Lower Highs are called Change of Character (Coc or CoCh).

When the price closes above the SPH, the uptrend is confirmed.

When the price closes below the SPL, the downtrend is confirmed.

SPH forms in uptrends, while SPL forms in downtrends.

Each time the price closes above the SPH, a new CoCh price forms. Vice versa when the price closes below SPL.

CoCh can act as an effective trailing stop to protect gains on trade positions.

In an uptrend, CoCh is the lowest point between the SPH and the candle that closes above the SPH.

In a downtrend, CoCh is the highest point between the SPL and the candle that closes below the SPL.

_images/line-structure.png

See this youtube video: How To Understand Market Structure for a deeper understanding.