— Allow the selection of one of 3 color schemes, each containing a pair of bull/bear colors.
— Generate 10-level gradients for each color.
— Use two types of gradient calculations: one for unbounded and one for bounded signals. We call the 2 modes: Advance/Decline and Relative.
These gradients are designed to work with 2 base colors for each element you want to color: one color for and one for conditions. Each base color can be generated in 10 shades, for a total of 20 possibilities for each graphic element (e.g., the fill between two MAs or a histogram). Each gradient is expressed internally as a float from zero to ten. Any value <= 1 returns the lightest shade. Any value > 9 returns the brightest shade.
Two modes of gradient generation are offered:
This mode is better for unbounded signals. To determine brightness, it uses advances/declines of the signal rather than its relative position in a fixed range.
► 2. Relative
This mode is preferable for bounded signals such as . It uses the relative position of the signal to determine the gradient.
— For demonstration purposes, this script allows coders to play with the settings of the signals used to generate examples of both gradient modes.
— The code is pretty fast.
— Doesn't require extra plots.
— All color schemes performs well on both light and dark chart backgrounds.
— These are simple gradients with only 10 levels, which will nonetheless provide more visual information than uniform colors. While the transitions are relatively smooth, the lack of depth in the number of shades will produce rather coarse gradients compared to high-quality graphic functions which will also typically be slower.
— The code structure makes it relatively easy to add color schemes. When doing so, you may need to fine-tune the transparencies of some colors, especially ones towards the extremities. For better compatibility, you should validate that your choices perform well on both dark and white chart backgrounds.
— For any given base color, the same color is used for all gradients of that base color. Only the transparency varies. If you wanted 100% opaque gradients, you would need to find the zero (or "ff" in hex) transparency RGB equivalents required for each of a base color's 10 gradients.
— While the gradients are currently composed of different brightness levels of the same base color, you could also configure them using different hues completely (e.g., rainbow color). It's up to you.
In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.