Virat-LevelsCollect 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.
Chỉ báo






















