Builds a color from red, green and blue values from 0 to 255, with optional transparency.
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
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 colorArguments
| Name | Type | Default | Description |
|---|---|---|---|
| red | const/ | required | Red channel from 0 to 255. |
| green | const/ | required | Green channel from 0 to 255. |
| blue | const/ | required | Blue channel from 0 to 255. |
| transp | const/ | 0 | Transparency 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
//@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