Skip to content
ChartDeck ChartScript docs Account Open the terminal

color

Types a colour value (color(na)).

#Functions

#colorfunction

Types a colour value (color(na)).

color(x: color): color
ParameterTypeDescription
xcolorThe value.

Returns color.

Example

ChartScriptFragmentOpen in editor
const c = color(na)

Since ChartScript 1

#color.bfunction

The blue component (0-255).

color.b(color: color): float
ParameterTypeDescription
colorcolorThe colour.

Returns float.

Example

ChartScriptFragmentOpen in editor
const v = color.b(color.orange)

Since ChartScript 1

#color.from_gradientfunction

A colour between bottom_color and top_color by where value sits.

color.from_gradient(value: float, bottom_value: float, top_value: float, bottom_color: color, top_color: color): color
ParameterTypeDescription
valuefloatThe value.
bottom_valuefloatThe value of the bottom colour.
top_valuefloatThe value of the top colour.
bottom_colorcolorThe colour at bottom_value.
top_colorcolorThe colour at top_value.

Returns color.

Example

ChartScriptFragmentOpen in editor
const c = color.from_gradient(ta.rsi(close, 14), 30, 70, color.down, color.up)

Since ChartScript 1

#color.gfunction

The green component (0-255).

color.g(color: color): float
ParameterTypeDescription
colorcolorThe colour.

Returns float.

Example

ChartScriptFragmentOpen in editor
const v = color.g(color.orange)

Since ChartScript 1

#color.newfunction

The colour with a new transparency (theme colours stay theme colours).

color.new(color: color, transp: float): color
ParameterTypeDescription
colorcolorThe colour.
transpfloatTransparency from 0 (opaque) to 100 (invisible).

Returns color.

Example

ChartScriptFragmentOpen in editor
const c = color.new(color.up, 50)

Since ChartScript 1

#color.rfunction

The red component (0-255).

color.r(color: color): float
ParameterTypeDescription
colorcolorThe colour.

Returns float.

Example

ChartScriptFragmentOpen in editor
const v = color.r(color.orange)

Since ChartScript 1

#color.rgbfunction

A colour from red, green and blue.

color.rgb(red: float, green: float, blue: float, { transp?: float = 0 }): color
ParameterTypeDescription
redfloatRed (0-255).
greenfloatGreen (0-255).
bluefloatBlue (0-255).
transpfloatdefault 0Transparency from 0 (opaque) to 100 (invisible).

Returns color.

Example

ChartScriptFragmentOpen in editor
const c = color.rgb(255, 128, 0)

Since ChartScript 1

#color.tfunction

The transparency (0-100).

color.t(color: color): float
ParameterTypeDescription
colorcolorThe colour.

Returns float.

Example

ChartScriptFragmentOpen in editor
const v = color.t(color.new(color.red, 40))

Since ChartScript 1

#color.themefunction

One colour per chart theme: dark, light and high-contrast (light / hc fall back to dark). The script re-runs when the theme changes.

color.theme(dark: color, { light?: color = na, hc?: color = na }): color
ParameterTypeDescription
darkcolorThe colour on a dark chart.
lightcolordefault naOn a light chart.
hccolordefault naOn a high-contrast chart.

Returns simple color.

Example

ChartScriptFragmentOpen in editor
const c = color.theme({ dark: #26A69A, light: #00897B, hc: #00FFB0 })

Since ChartScript 1

#Constants

NameTypeDescription
color.accentcolorTheme colour "accent": follows the chart look (dark, light, high contrast, colour-blind).
color.ambercolorTheme colour "amber": the chart's amber (gold) series colour, the one the built-in studies draw with; follows the chart look (dark, light, high contrast, colour-blind).
color.aquacolorNamed colour aqua (#00BCD4).
color.blackcolorNamed colour black (#363A45).
color.bluecolorNamed colour blue (#2196F3).
color.cyancolorTheme colour "cyan": the chart's cyan series colour, the one the built-in studies draw with; follows the chart look (dark, light, high contrast, colour-blind).
color.downcolorTheme colour "down": follows the chart look (dark, light, high contrast, colour-blind).
color.fuchsiacolorNamed colour fuchsia (#E040FB).
color.graycolorNamed colour gray (#787B86).
color.greencolorNamed colour green (#4CAF50).
color.gridcolorTheme colour "grid": follows the chart look (dark, light, high contrast, colour-blind).
color.limecolorNamed colour lime (#00E676).
color.magentacolorTheme colour "magenta": the chart's magenta (pink) series colour, the one the built-in studies draw with; follows the chart look (dark, light, high contrast, colour-blind).
color.marooncolorNamed colour maroon (#880E4F).
color.mutedcolorTheme colour "muted": follows the chart look (dark, light, high contrast, colour-blind).
color.navycolorNamed colour navy (#311B92).
color.olivecolorNamed colour olive (#808000).
color.orangecolorNamed colour orange (#FF9800).
color.purplecolorNamed colour purple (#9C27B0).
color.redcolorNamed colour red (#F23645).
color.silvercolorNamed colour silver (#B2B5BE).
color.tealcolorNamed colour teal (#089981).
color.textcolorTheme colour "text": follows the chart look (dark, light, high contrast, colour-blind).
color.upcolorTheme colour "up": follows the chart look (dark, light, high contrast, colour-blind).
color.violetcolorTheme colour "violet": the chart's violet (lilac) series colour, the one the built-in studies draw with; follows the chart look (dark, light, high contrast, colour-blind).
color.whitecolorNamed colour white (#FFFFFF).
color.yellowcolorNamed colour yellow (#FDD835).

The ChartScript documentation is in English for now; translations will follow.