ScriptingReferenceFunctionscolorcolor.new

color.new

Takes a colour and an opacity, and returns that colour at that opacity. Opacity runs from 0 to 1, where 1 is solid and 0 invisible. A value outside the range is clamped to it rather than rejected, so an out-of-range number neither fails the script nor warns you.

color.new(const color color, const float alpha) → const color
color.new(input color color, input float alpha) → input color
color.new(series color color, series float alpha) → series color
color.new(simple color color, simple float alpha) → simple color
ParameterTypeRequiredDescription
colorconst coloryesthe colour to set an opacity on
alphaconst floatyesthe opacity to apply, from 0 to 1

Returns const color or input color or series color or simple color — A colour in the form of the arguments you pass, or na where either argument is na.

indicator("Opacity")
plot(close, title = "Close", color = color.new(color.blue, 0.6))

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