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 colorcolor.new(input color color, input float alpha) → input colorcolor.new(series color color, series float alpha) → series colorcolor.new(simple color color, simple float alpha) → simple color| Parameter | Type | Required | Description |
|---|---|---|---|
color | const color | yes | the colour to set an opacity on |
alpha | const float | yes | the 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.