OPEN-SOURCE SCRIPT
Light or Dark Mode Tutorial - Luminance Detection

As a colorblind trader, I think accessibility is a big deal. This script auto detects the chart background color and optimizes text color based on luminance.
Luminance detection is based on pine script new chart.bg_color feature, allowing lines, tables, etc to be optimized. Thanks to TV team for releasing this in the latest update/blog post today! This makes it simple to optimize scripts based off the knowledge that max luminance = 765 (rgb 255 + 255 + 255), thus we know that lum <= 383 is "dark mode" and lum > 383 is "light mode".
Try changing the chart background color and see how this script changes the table printed on the chart. I hope more script authors will begin to utilize this concept and that even better contrast detection may be built future pine script iterations.
Luminance detection is based on pine script new chart.bg_color feature, allowing lines, tables, etc to be optimized. Thanks to TV team for releasing this in the latest update/blog post today! This makes it simple to optimize scripts based off the knowledge that max luminance = 765 (rgb 255 + 255 + 255), thus we know that lum <= 383 is "dark mode" and lum > 383 is "light mode".
Try changing the chart background color and see how this script changes the table printed on the chart. I hope more script authors will begin to utilize this concept and that even better contrast detection may be built future pine script iterations.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
❤️ Premium indicator subscription @ Whop includes: Mojo Levels, Manipulation Model, Super Oscillator, VIX Meter, and Volatility Radar
🔗 whop.com/c/upslidedown/t use discount code FRIENDOFUSD for 20% off FOREVER
🔗 whop.com/c/upslidedown/t use discount code FRIENDOFUSD for 20% off FOREVER
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
For quick access on a chart, add this script to your favorites — learn more here.
❤️ Premium indicator subscription @ Whop includes: Mojo Levels, Manipulation Model, Super Oscillator, VIX Meter, and Volatility Radar
🔗 whop.com/c/upslidedown/t use discount code FRIENDOFUSD for 20% off FOREVER
🔗 whop.com/c/upslidedown/t use discount code FRIENDOFUSD for 20% off FOREVER
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.