I have created an algorithm that draws levels on a chart. The algorithm can be easily customized as you need.
This algorithm can help both intuitive and system traders. Intuitive traders just look at the drawn lines. For system traders, the "levels" array stores all level values. Thus, you can use these values for algorithmic trading.
It should be noted that this algorithm is difficult to use on small timeframes due to the limited capabilities of the Pine Script. We can reference a maximum of 5000 historical bars in cycles. Also, the script may receive an error due to a long calculation. Therefore, do not ask too much of the algorithm on small timeframes.