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
- Literal
- Theme
- Series
- Parameter
A fixed color.
Changing a color
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):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: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.