OPEN-SOURCE SCRIPT

Virat-Levels

384
Collect all active levels (value + label + color) into arrays — skipping any that are na or toggled off.

Sort all three arrays together by price using bubble sort, so levels are in order from bottom to top.

walk up the sorted list and if any label's Y is within min_gap of the one below it, push it up by the difference. The min_gap is 1.5% of the 200-bar price range, so it auto-scales — works on a $2 stock and a $500 stock equally.

lines are always drawn at the true price (so the line sits exactly on the level), but labels are drawn at the nudged Y (so they don't stack on top of each other). The line still points accurately to the real price, the label just floats slightly above/below if needed.

免责声明

这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。