The DRAW_HISTOGRAM style draws a histogram as a sequence of columns of a specified color from zero to a specified value. Values are taken from the indicator buffer. The width, color and style of the column can be specified like for the DRAW_LINE 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_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, Bears Power or OsMA. For the empty non-displayable values the zero value should be specified.
The number of buffers required for plotting DRAW_HISTOGRAM is 1.
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.
Note that initially for plot1 with DRAW_HISTOGRAM the properties are set using the compiler directive #property, and then in the OnCalculate() function these three properties are set randomly. 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).