The DRAW_COLOR_ZIGZAG style draws segments of different colors, using the values of two indicator buffers. This style is a colored version of DRAW_ZIGZAG, i.e. allows specifying for each segment an individual color from the predefined set of colors. The segments are plotted from a value in the first buffer to a value in the second indicator buffer. None of the buffers can contain only empty values, since in this case nothing is plotted.
The width, color and style of the line can be specified like for the DRAW_ZIGZAG style - using compiler directives or 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.
Sections are drawn from a non-empty value of one buffer to a non-empty value of another indicator buffer. To specify what value should be considered as "empty", set this value in the PLOT_EMPTY_VALUE property:
Always explicitly fill in the of the indicator buffers, set an empty value in a buffer to skip bars.
The number of buffers required for plotting DRAW_COLOR_ZIGZAG is 3:
•two buffers to store the values of ends of the zigzag sections;
•one buffer to store the color index, which is used to draw the section (it makes sense to set only non-empty values).
An example of the indicator that plots a saw based on the High and Low prices. The color, width and style of the zigzag lines change randomly every N ticks.
Please note that for plot1 with the DRAW_COLOR_ZIGZAG style, 8 colors are set using the compiler directive #property, and then in the OnCalculate() function the color is selected randomly from the 14 colors stored in the colors array.
The N parameter is set in external parameters of the indicator for the possibility of manual configuration (the Parameters tab in the indicator's Properties window).