Colours are probably the most important way in which TradingView scripts communicate events, like highlighting the chart’s background whenever a moving average crossover happens. In this chapter we discuss how we can use colours in TradingView scripts.

In this article:

Using colours in TradingView manually and programmatically

This chapter on TradingView colours starts with changing a script’s colours by hand. In that article we discuss which options specify the appearance of an indicator or strategy, and how the Pine code affects the name of the settings and whether they can be changed or not.

Then we look at the different colours available in TradingView Pine:

  • In coding with TradingView’s basic colours we discuss the 17 built-in colour variables (like red, green, and yellow; TradingView, n.d.) and how we can use these.
  • Besides those standard colours, TradingView also allows hexadecimal colour values. These start with the # sign followed by 6 hexadecimal digits that correspond to a RGB value (Pine Script Language Tutorial, n.d.). In working with hexadecimal colours in TradingView we discuss these colours and look at several lists with different hexadecimal colour options.

When programming in TradingView, those two kinds of colours – basic colours and hexadecimal colour values – can be used with these functions (TradingView, n.d.):

Function Description
barcolor() Sets the colour of price bars of the chart’s instrument.
bgcolor() Fills the chart’s background with a colour.
fill() Colours a background section that’s between two plots or two horizontal lines.
hline() Draws a horizontal, coloured line at the specified price level.
plot() Plots a series of data with a certain colour.
plotarrow() Plots coloured up and down arrows.
plotbar() Plots OHLC bars in a particular colour.
plotcandle() Plots coloured price candles.
plotchar() Displays a coloured Unicode character.
plotshape() Plots arrows, circles, and other visual shapes with a specified colour.

After discussing TradingView’s different colour values, we look at a curious feature in the next article:

Applying colours programmatically in TradingView Pine

The second part of the chapter looks at how we can use the basic colours and hexadecimal colour values in our indicator and strategy scripts:

Then we look at some of the ways in which we can use colours in TradingView:

We end the chapter with a summary of colours in TradingView. To learn more about other topics, see all TradingView programming tutorials.


References

Pine Script Language Tutorial (n.d.). Retrieved on October 23, 2015, from https://docs.google.com/document/d/1sCfC873xJEMV7MGzt1L70JTStTE9kcG2q-LDuWWkBeY/

TradingView (n.d.). Script Language Reference Manual. Retrieved on February 16, 2016, from https://www.tradingview.com/study-script-reference/