ScriptingReferenceFunctionscolorcolor.rgb

color.rgb

Builds a colour from red, green and blue components, with an optional opacity. Two scales meet in one call: the components run from 0 to 255 and the opacity from 0 to 1. Leave the opacity out and the colour is solid; components and opacity are both clamped to their range.

color.rgb(const int r, const int g, const int b, const float a) → const color
color.rgb(input int r, input int g, input int b, input float a) → input color
color.rgb(series int r, series int g, series int b, series float a) → series color
color.rgb(simple int r, simple int g, simple int b, simple float a) → simple color
ParameterTypeRequiredDescription
rconst intyesthe red component, from 0 to 255
gconst intyesthe green component, from 0 to 255
bconst intyesthe blue component, from 0 to 255
aconst floatnooptional; the opacity, from 0 to 1, defaulting to solid

Returns const color or input color or series color or simple color — A colour in the form of the arguments you pass.

indicator("Colour from components")
plot(close, title = "Close", color = color.rgb(255, 152, 0))

See also colour · color.a · color.b · color.g

Part of the function index.

Ready to put this into practice?
Try GoCharting Premium
Unlock advanced orderflow, market profile, options desk, and real-time data — everything you just read about, live in your charts.
Upgrade