OPEN-SOURCE SCRIPT
Virat-Levels

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.
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.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.