Sidechair

color.rgb()

Browse the reference

Builds a color from red, green and blue values from 0 to 255, with optional transparency.

Try it in the editor

color.rgb(red, green, blue) mixes three channels. Each runs from 0 to 255, and (255, 0, 0) is pure red.

The optional fourth argument sets transparency from 0 to 100, with 0 as the default. Channel values outside 0 to 255 are clamped and fractions are rounded.

Syntax

Pine Script
color.rgb(red: series int/float, green: series int/float, blue: series int/float, transp: series int/float (optional)) -> series color
color.rgb(red: const int/float, green: const int/float, blue: const int/float, transp: const int/float (optional)) -> const color
color.rgb(red: input int/float, green: input int/float, blue: input int/float, transp: input int/float (optional)) -> input color
color.rgb(red: simple int/float, green: simple int/float, blue: simple int/float, transp: simple int/float (optional)) -> simple color

Arguments

NameTypeDefaultDescription
redconst/input/simple/series int/floatrequiredRed channel from 0 to 255.
greenconst/input/simple/series int/floatrequiredGreen channel from 0 to 255.
blueconst/input/simple/series int/floatrequiredBlue channel from 0 to 255.
transpconst/input/simple/series int/float0Transparency from 0 (solid) to 100 (invisible).

Returns

const/input/simple/series color: the color; na if any channel is na.

Remarks

  • Channels can be series, so you can compute a color from data on each bar.

Example

Pine ScriptHeat color from RSIOpen in editor
//@version=6
indicator("RSI heat")
r = ta.rsi(close, 14)
heat = color.rgb(255 * r / 100, 80, 255 * (1 - r / 100))
plot(r, "RSI", color = heat, linewidth = 3)

See also

Runs on Sidechair