Sidechair

color.r()

Browse the reference

Returns the red channel of a color as a number from 0 to 255.

Try it in the editor

color.r reads the red part of a color. Pure red gives 255 and black gives 0.

Transparency does not change the channel value. Rebuild a color from its parts with color.rgb.

Syntax

Pine Script
color.r(color: series color) -> series float
color.r(color: const color) -> const float
color.r(color: input color) -> input float
color.r(color: simple color) -> simple float

Arguments

NameTypeDefaultDescription
colorconst/input/simple/series colorrequiredThe color to take the red part from. na gives na.

Returns

const/input/simple/series float: the red value from 0 to 255; na if the color is na.

Remarks

Example

Pine ScriptRed of a built-in colorOpen in editor
//@version=6
indicator("Red channel")
c = color.orange
plot(color.r(c), "Red", color = color.red)
plot(color.g(c), "Green", color = color.green)
plot(color.b(c), "Blue", color = color.blue)

See also

Runs on Sidechair