Skip to main content
Colors are of type ColorRef. A ColorRef does not only hold a color: it holds where the color comes from. The chart resolves it when it draws, so a point colored with “the first color of this series” follows the settings of the user, and a theme color follows the light and the dark theme, without recalculating the indicator. This is also what lets an indicator run on the server, which knows neither the theme nor the settings of each user.

Sources of a color

A fixed color.

Changing a color

Both keep the references: a fade between a series color and a parameter still follows both.

Changes bound to a parameter

Four changes can take their value from a parameter of the indicator, so the user changes them without a new calculation (see Parameters resolved by the chart):
Call them in this order: WithOpacity, WithOpacityScale, WithOpacityWhen, WithEnable. Each one drops what the ones after it have set: a WithOpacity called last removes the other three. With a plain value instead of a parameter, the change is applied at once.

Defaults for series and parameters

Use theme colors as defaults, so the indicator looks right on every theme the first time it is added:
Do not use IMethodAPI.GetColorForTheme: it returns the resolved color and exists only on the desktop. GetColorRefForTheme returns the reference and works everywhere. VAn.GetChartBackColor(), the background the user set for the chart, is desktop only too: on the server it is Transparent.

Where colors are used

A point without a color of its own takes the color of its series. Set point colors only when they change from point to point, and set OverrideAutoColor = true on the series attribute when you do.