PINE LIBRARY

Dark & Light Theme [TradingFinder] Switching Colors Library

🔵Introduction

One of the challenges of script users is matching the colors used in indicators or strategies. By default, colors are chosen to display based on either the dark theme or the light theme.

In scripts with a large number of colors used, changing all colors to better display in dark mode or light mode can be a difficult and tedious process.

This library provides developers with the ability to adjust the colors used in their scripts based on the theme of the display.

🔵Logic

To categorize the color spectrum, the range from 0 to 255 of all three main colors red, green and blue was divided into smaller ranges.

Blue color, which is more effective in darkening or lightening colors, is divided into 8 categories, red color into 5 categories, and green color into 3 categories, because it has little effect on darkening or brightening colors.

The combination of these categories creates 120 different modes for the color range, which leads to a more accurate identification of the color and its brightness, and helps to decide how to change it.

Except for these 120 modes, there are 2 other modes that are related to colors almost white or black, which makes a total of 122 modes.


snapshot


🔵How to Use

First, you can add the library to your code as shown in the example below.




🟣Parameters



Color: In this parameter, enter the color you want to adjust based on light mode and dark mode.

Mode: Three modes "Off", "Light" and "Dark" are included in this parameter. "Light" mode is for color adjustment for use in "Light Mode".

"Dark" mode is for color adjustment for use in "Dark Mode" and "Off" mode turns off the color adjustment function and the input color to the function is the same as the output color.


snapshot



snapshot



snapshot



🔵Function Outputs


chartcolorsdisplayformattingpinepinecodepinescriptstylethemethemestradingfinderutilities

Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.


Get Access to TradingFinder indicators and Education for FREE: tradingFinder.com/

Forex, Crypto, Stocks, Futures & Index informational materials and Trading Tools in Turkish language: tradingFinder.com/tr/
Also on:

Disclaimer