Situation: You want to apply colours to your indicator or strategy and are wondering what the typical TradingView colours are.

In this article:

Solution: an overview of TradingView’s standard colours

TradingView has 17 built-in colour variables that each stand for a specific colour. They have easy-to-remember names and represent different colours. Those standard colours are (TradingView, n.d.; TradingView Wiki, 2017):

Colour variable Hexadecimal equivalent Example
aqua #00FFFF
black #000000
blue #0000FF
fuchsia #FF00FF
gray #808080
green #008000
lime #00FF00
maroon #800000
navy #000080
olive #808000
orange #FF7F00
purple #800080
red #FF0000
silver #C0C0C0
teal #008080
white #FFFFFF
yellow #FFFF00
Note: Besides these colour variables we can also colour with hexadecimal values. That makes countless different colours possible, but is also a bit more complex. For instance, instead of typing red we’d have to use the #FF0000 value.

Example: plot 5 moving averages in different colours

The example below uses five different colours (green, fuchsia, maroon, silver, and olive). Each colours an Exponential Moving Average (EMA) plot. With input options we set those averages to a length of 12, 24, 36, 48, and 60 bars. We do the actual plotting with the plot() function, and make each EMA display as a line plot. With the color argument of plot() we apply one of those standard TradingView colours.

//@version=3
study(title="Recipe - standard colours", overlay=true)

// Create input options
priceData = input(title="Price data", type=source, defval=close)
ema1 = input(title="EMA 1", type=integer, defval=12)
ema2 = input(title="EMA 2", type=integer, defval=24)
ema3 = input(title="EMA 3", type=integer, defval=36)
ema4 = input(title="EMA 4", type=integer, defval=48)
ema5 = input(title="EMA 5", type=integer, defval=60)

// Plot values
plot(series=ema(priceData, ema1), color=green, linewidth=2)
plot(series=ema(priceData, ema2), color=fuchsia, linewidth=2)
plot(series=ema(priceData, ema3), color=maroon, linewidth=2)
plot(series=ema(priceData, ema4), color=silver, linewidth=2)
plot(series=ema(priceData, ema5), color=olive, linewidth=2)

The five EMAs and their different colours look like this:

Example TradingView chart with colours moving averages

Discussion: working with standard TradingView colours

To use the standard TradingView colours discussed above, we have to add a function to our indicator or strategy that accepts colours. The following functions can all work with colours (TradingView, n.d.):

Function Description
barcolor() Sets the colour of the price bars from the chart’s instrument.
bgcolor() Changes the chart’s background colour.
color() Creates a transparent colour based on a TradingView standard colour or hexadecimal colour value. We can then plot or draw something with that transparent colour (see the other functions in this table).
fill() Fills the background between two plots or two horizontal lines with a certain colour.
hline() Draws a horizontal line at a fixed price level in a certain colour.
plot() Plots a series of data on the chartwith a certain colour.
plotarrow() Plots a coloured up or down arrow on the chart.
plotbar() Plots a coloured OHLC bar on the chart.
plotcandle() Plots coloured candlesticks on the chart.
plotchar() Displays a text character on the price chart with a certain colour.
plotshape() Displays a visual shape (like a cross or diamond) on the price chart with a specific colour.
Note: With each of these functions we can plot or draw in a certain colour. But that colour isn’t always the one we see on the chart. That happens when we repeatedly add the same script to the chart. In that case TradingView uses different colours for each instance of that script. That does make it easier to tell the different script copies apart. But it also means we sometimes get different colours than we programmed in our indicator or strategy.

While the standard TradingView colours limit us to 17 ones, hexadecimal colour values make it possible to use any colour we want. And with transparent colours we have even more colour options.

Learn more:


References

TradingView (n.d.). Pine Script Language Reference Manual. Retrieved on June 5, 2017, from https://www.tradingview.com/study-script-reference/

TradingView Wiki (2017, March 24). Type System. Retrieved on June 5, 2017, from https://www.tradingview.com/wiki/Type_System