DefineColor

DefineColor ( String name, CustomColor color);

Description

Defines a named color for a plot with the default color value. This color can be changed in the Edit Studies dialog.

Input parameters

Parameter Default value Description
name - Defines the name of the color.
color - Defines color to be used with specified name.

Example

declare lower;
input length = 12;
plot Momentum = close - close[length];
Momentum.DefineColor("Positive", Color.UPTICK);
Momentum.DefineColor("Negative", Color.DOWNTICK);
Momentum.AssignValueColor(if Momentum >= 0 then Momentum.Color("Positive") else Momentum.Color("Negative"));

This example paints the Momentum plot in different colors according to its trend. The DefineColor function defines Positive and Negative color names as aliases for Color.UPTICK and Color.DOWNTICK constants. You can change the colors in the Edit Studies dialog and their order is the same as in the source code. If the trend of the plot is positive then it is painted in Positive (Uptick) color. If the trend is negative, the plot is painted in Negative (Downtick) color.

Note that in order to refer to a specific color the code uses the Color function.