The DRAW_COLOR_LINE value is a colored variant of the DRAW_LINE style; it also draws a line using the values of the indicator buffer. But this style, like all color styles with the word COLOR in their title has an additional special indicator buffer that stores the color index (number) from a specially set array of colors. Thus, the color of each line segment can be defined by specifying the color index of the index to draw the line at this bar.
The width, style and colors of lines can be set using the compiler directives and dynamically using the PlotIndexSetInteger() function. Dynamic changes of the plotting properties allows "to enliven" indicators, so that their appearance changes depending on the current situation.
The number of buffers required for plotting DRAW_COLOR_LINE is 2.
Colors can be specified by the compiler directive #property indicator_color1 separated by a comma. The number of colors cannot exceed 64.
An example of the indicator that draws a line using Close prices of bars. The line width and style change randomly every N=5 ticks.
The colors of the line segments also change randomly in the custom function ChangeColors().
The example shows the feature of the "color" versions of indicators - to change the color of a line segment, you do not need to change values in the ColorLineColors buffer (which contains the color indexes). All you need to do is set new colors in a special array. This allows you to quickly change the color once for the entire plotting, changing only a small array of colors using the PlotIndexSetInteger() function.
The N and Length (the length of color segments in bars) parameters are set in external parameters of the indicator for the possibility of manual configuration (the Parameters tab in the indicator's Properties window).