The DRAW_COLOR_HISTOGRAM style draws a histogram as a sequence of colored columns from zero to a specified value. Values are taken from the indicator buffer. Each column can have its own color from a predefined set of colors.
The width, color and style of the histogram can be specified like for the DRAW_HISTOGRAM style - using compiler directives or dynamically using the PlotIndexSetInteger() function. Dynamic changes of the plotting properties allows changing the look of the histogram based on the current situation.
Since a column from the zero level is drawn on each bar, DRAW_COLOR_HISTOGRAM should better be used in a separate chart window. Most often this type of plotting is used to create indicators of the oscillator type, for example, Awesome Oscillator or Market Facilitation Index. For the empty non-displayable values the zero value should be specified.
The number of buffers required for plotting DRAW_COLOR_HISTOGRAM is 2.
Colors can be specified using 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 sinusoid of a specified color based on the MathSin() function. The color, width and style of all histogram columns change randomly each N ticks. The bars parameter specifies the period of the sinusoid, that is after the specified number of bars the sinusoid will repeat the cycle.
Please note that for plot1 with the DRAW_COLOR_HISTOGRAM style, 5 colors are set using the compiler directive #property, and then in the OnCalculate() function the colors are 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).