Sidechair

chart.fg_color

Browse the reference

A color that reads against the chart background: dark on a light chart, light on a dark one.

Try it in the editor

Use it for text, borders and lines that must stay readable whichever theme the chart uses. It has the input qualifier, so the script runs again when the chart's theme changes.

Take the color from here instead of hard-coding color.white or color.black, each of which disappears on one of the two themes. Add transparency with color.new() for faint grid-like marks.

Type

input color

Remarks

  • On Sidechair: the color follows the dark chart theme.

Example

Pine ScriptTheme-proof label and a faint guide lineOpen in editor
//@version=6
indicator("chart.fg_color: readable on any theme", overlay = true)
plot(ta.sma(close, 50), "SMA 50", color.new(chart.fg_color, 70))
if barstate.islast
    label.new(bar_index, high, "Last", color = color.new(chart.fg_color, 85), textcolor = chart.fg_color)

See also

Runs on Sidechair