Detecting Support and Resistance Levels

Support & Resistance levels are essential for every trader. The define the decision points of the markets. If you are long and the market falls below the previous support level, you most probably have got the wrong position and better exit.

The detection of support and resistance levels is usually highly subjective and based on the analysts experience. In this article I will use a simple algorithm to detect the levels and show them on the chart.

The first and second deviation of a curve

If you remember your high school math class you have heard about the first and second deviation of a curve and how to use it to find the turning points and extremes of a curve,

The deviation of a curve is nothing else than the momentum of a curve. It defines the slope of the curve. If the slope of a curve is zero, you have found a local extreme. The curve will change from rising to falling or the other way round.

The second deviation, or the momentum of momentum, shows you the turning points of the first deviation. This is important, as at this point the original curve will switch from acceleration to break mode.

But don’t worry about the theory behind the indicator, see the chart below to get the idea.

First the market data is smoothed.

Second the momentum of the market is calculated. Third the momentum of the momentum is calculated.

If the second momentum crosses above zero, the first momentum will have local low and the market will be in a state when the trend comes to an end.

Support and Resistance explanation

Algorithmic turning points

Using the logic laid out above the support&resistance indicator will show the turning points of the market in a timely manner.

Depending on level of market-smoothing it will show the long term or short term turning points.

support and resistance

If you are a trend follower you might only be interested in support levels. Therefore I added the possibility to use the Wells-Wilder Directional Movement Index as a trend filter.

support and resistance DMI filter

Tradesignal indicator code

I used the Tradesignal software suite to program this indicator. The code used is shown below.

It first calculates the first and second deviation of the smoothed market, and in a second step runs the turning point detection.

Tradesignal indicator code

Analysis done using the Tradesignal software suite and data from Refinitiv. Thanks!