Sidechair

color.g()

Browse the reference

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

Try it in the editor

color.g reads the green part of a color. Pure green gives 255 and black gives 0.

A fully transparent color keeps its green value, since transparency is stored apart from the channels.

Syntax

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

Arguments

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

Returns

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

Remarks

Example

Pine ScriptGreen of a gradientOpen in editor
//@version=6
indicator("Green channel")
c = color.from_gradient(ta.rsi(close, 14), 30, 70, color.red, color.green)
plot(color.g(c), "Green", color = color.green)

See also

Runs on Sidechair