How to change colors of indicators, bars or backgrounds in Tradingview pinescript v5 (2023)

Pine Script, the custom scripting language powering TradingView, empowers traders to create personalized indicators and strategies. While the focus often revolves around precise calculations and strategies, the importance of colors in Pine Script are often overlooked
And in today’s blog post I’ll show you exactly how you can change colors in Tradingview pinescript v5.

Tradingview example of what you will learn

I changed the colors of an indicator, the bars and changed to custom colors for the background with RGB and Hexadecimal values:

Image showing use of colors for an indicator, bars and a background using custom RGB and Hexadecimal colors in Tradingview Pinescript V5

What are the colors in Tradingview by default?

Before we delve into using colors, let's explore the foundation of Pine Script standard colors with built-in functions and constants. Discover the basic colors like black, white, red, green, and blue, as well as more subtle colors. Additionally, we'll decipher the versatility of RGB color values and how they open a world of possibilities.

TradingView’s Pine Script offers many constants for picking a color. You can apply the colors to indicators, bars, and backgrounds. We will show an example of each. The constants are:

ColorPinescript v5 code
Aquacolor = color.aqua
Blackcolor = color.aqua
Bluecolor = color.aqua
Fuchsiacolor = color.aqua
Graycolor = color.aqua
Greencolor = color.aqua
Limecolor = color.aqua
Marooncolor = color.aqua
Navycolor = color.aqua
Olivecolor = color.aqua
Orangecolor = color.aqua
Purplecolor = color.aqua
Redcolor = color.aqua
Silvercolor = color.aqua
Tealcolor = color.aqua
Whitecolor = color.aqua
Yellowcolor = color.aqua

Custom color

Image showing use of custom RGB and Hexadecimal colors in Tradingview Pinescript V5

It is also possible to pick a custom color. This is done with RGB values, or you can select a color with your cursor.

Change colors of Tradingview indicators

Assigning a color to an indicator is the most common option. Enhance the visual representation of data in your indicators and plots with a well-chosen color. This can offer valuable insights and make your trading signals more informative. Moreover the color you pick for your indicators will help them stand out from each other and can help you make decisions faster. Or you can show that the indicators are closely related.

An example of a colored indicator:

Image how to add color to indicators in Tradingview Pinescript V5

//@version=5 indicator(title="colors", overlay=true)
//indicator moving average in color fuchsia
plot(ta.sma(close,20), color=color.fuchsia, title="ta.sma(close,20)")

Change colors of Tradingview bars

I use color bars to signal changes in the price. This helps me understand the patterns the price makes in a flash. The difference between changing market conditions can be small, and this helps me see changes more clearly.

An example of a colored bar:

Image how to add color to bars in Tradingview Pinescript V5

//@version=5 indicator(title="colors", overlay=true)
//Bar color if the current open price is higher than the previous bar's open price, green; otherwise, orange
barcolor(open > open[1] ? color.lime : color.orange)

Change colors of Tradingviews background

To indicate a bear or bull period, I often use the feature background color in Tradingview. Based on the conditions I've specified the background will change color, I often use read and green. This will enable me to quickly tell which side of the market I want to be on. Do I want to take a short or a long position? I’ve also used this to monitor my automated trades. The background turns green if my robot should be in a long position and red when I should be in a short position. I use MetaTrader 4 to create these automated trades and can spot my positions in their app. But the visual representation of TradingView offers me the security and ability to check whether all is well in a second.

An example of a colored background:

Image how to add color to the background in Tradingview Pinescript V5

//@version=5 indicator(title="colors", overlay=true)
//Background color if the open price is higher than the moving average of 20, or else orange
bgcolor(open > ta.sma(close,20) ? color.aqua : color.silver)

Tips for Using Colors in Pinescript v5

Mind the psychology of colors and understand how color choices can influence emotions and readability. Red and green usually trigger emotions, if you’ve suffered, try different colors. Or even better, switch to automated trading. You’ve noticed that we needed to code quite a lot of different settings. If you want to speed up your Pine Script indicator creation, you should check out our Pine Script code generator. This will enable you to create Pine Script code to create indicators in seconds. You can combine up to 20 indicators in one script and pick a color for each.

Conclusion

Unleash the captivating world of colors in Pine Script and transform your trading visualizations from ordinary to extraordinary. You’ve mastered the art of color. This will add an element of creative expression to your technical analysis, setting the stage for a more engaging and visually stunning trading experience. Embrace the endless possibilities and create a trading environment that truly reflects your unique style and personality!

Let us create a pinescript code for you!

Simply select your desired indicators, customize the parameters to suit your preferences, and let the Pinescript Generator do the heavy lifting for you, it is that simple.


Ready to start your automated trading journey?

  1. Register to the Trading Bot Generator
  2. Purchase a subscription to the Trading Bot Generator
  3. Sign in
  4. Watch the tutorial or follow the step by step guide
  5. Enjoy your trading robot or unlimited Tradingview indicators/strategies!

Register


Testimonials

4.1

out of

5

97 reviews

Great code generator!

The trading bot generator is a total game-changer! It simplifies the process of creating custom trading bots, saving me hours of coding. The wide range of indicators and customization options allows me to fine-tune my strategies easily. The web-based platform is user-friendly and accessible from anywhere. It has significantly improved my trading results. Highly recommended!

Jane

Unlimited Tradingview indicators without a tradingview subscription

I finally have a piece of my life back. I don't have to spend hours in front of a screen, but can just enjoy time with my friends. Moreover I am a frequent Tradingview user and enjoy multiple indicators without a Tradingview subscription. I've saved $45 a month

Jack

Creating a trading bot has never been easier, but documentation is sparse

The trading bot generator has made trading bots accessible to all skill levels. I can quickly assess the profitability of different strategies. If a strategy falls short, I can easily generate a new bot. The emotionless trading eliminates impulsive decisions. Comprehensive documentation could improve. Overall, a fantastic tool for boosting trading success.

Kate