Dear all, I have googled and tried many things. Right now I am stuck and looking for suggestions, ideas on where to look further.

I am looking for a strategy to automatically determine the support/resistance (S/R) levels in a graphical price chart.

Please see picture. The S/R lines is an example of what I like to achieve.

To simplify matter are horizontal S/R lines fully sufficient.

I have tried to find a line with the smallest square error. But ultimately, who to determine, which data points shall belong to which S/R line.

Further I have tried k-means clustering to somehow cleverly group data points to their S/R line with the shortest distance. But it clusters data points more around a radius than along a line.

Grateful for suggestions

s5804