Functions
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.
Syntax · 1 of 4
color.rgb(const int r, const int g, const int b, const float a) → const color
Arguments
r required const int Red color component. Possible values are from 0 to 255. g required const int Green color component. Possible values are from 0 to 255. b required const int Blue color component. Possible values are from 0 to 255. a const float 0 to 100, where 1 is fully opaque and 0 is fully transparent. Return Type
const color Syntax · 2 of 4
color.rgb(input int r, input int g, input int b, input float a) → input color
Arguments
r required input int Red color component. Possible values are from 0 to 255. g required input int Green color component. Possible values are from 0 to 255. b required input int Blue color component. Possible values are from 0 to 255. a input float 0 to 100, where 1 is fully opaque and 0 is fully transparent. Return Type
input color Syntax · 3 of 4
color.rgb(simple int r, simple int g, simple int b, simple float a) → simple color
Arguments
r required simple int Red color component. Possible values are from 0 to 255. g required simple int Green color component. Possible values are from 0 to 255. b required simple int Blue color component. Possible values are from 0 to 255. a simple float 0 to 100, where 1 is fully opaque and 0 is fully transparent. Return Type
simple color Syntax · 4 of 4
color.rgb(series int r, series int g, series int b, series float a) → series color
Arguments
r required series int Red color component. Possible values are from 0 to 255. g required series int Green color component. Possible values are from 0 to 255. b required series int Blue color component. Possible values are from 0 to 255. a series float 0 to 100, where 1 is fully opaque and 0 is fully transparent. Return Type
series color Example
//@lipi=2
indicator("color.rgb Example", overlay=true)
// Solid orange, and the same colour at 30% opacity
solid = color.rgb(255, 165, 0)
faded = color.rgb(255, 165, 0, 0.3)
plot(close, title="Close", color=solid, linewidth=2)
bgcolor(faded)