Color Gradient Framework - PineCoders FAQ

Provides a suite of functions to:
— 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 bullish and one for bearish 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 MACD 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:
► 1. Advance/Decline
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 RSI . 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.
Release Notes: Updated comments.
Release Notes: Tidied up code.
Release Notes: Tidied up code again )
Release Notes: Included a compact version of the functions at the end of the script.
Open-source script

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.

Want to use this script on a chart?
Tools and ideas for all Pine coders:
Our Pine FAQ & Code:
Pine news broadcasts: or


PineCoders on 🔥
+3 Reply
realy Realy thanks
+1 Reply
Wow guys! Thank you for that detailed tutorial! Amazing job!
+1 Reply
Colorful, well done, nice!
+1 Reply
PineCoders RootDuk
@RootDuk, Thx. Appreciate. It's a simple, hopefully easy to use and, from a performance point of view, low-cost way to improve the looks of our stuff.
please include in Pine color shemes like that. Start color, end color and a step point between @PineCoders Thank you.
Beautiful one!
PineCoders seatfive
@seatfive, Thx! Happy you and other authors like it. We should be adding a set of 16-color levels functions soon. Will provide more smoothness while still being fast enough for small numbers of fills.
You censor the best scripts on tradingview to promote your scam. You have no skill and no knowledge. When a script is pure quality you censor it. TradingView is the CNN of trading
PineCoders sevensphere
@sevensphere, Thanks for sharing your opinion.
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Private Messages Chat Sign Out