Skip to main content
A series draws one point per bar: a line, a histogram, a band, a marker. Use a series when the indicator has a value for every bar. For anything else (boxes, labels, levels) use annotations.

Declaring a series

A series is declared in two parts: an attribute class with its defaults, and a property which holds it.
The name passed to the base constructor identifies the series: it must be unique in the indicator, and it is what the workspace saves the settings under. The property is filled when the indicator is created. Series are plotted in the order they are declared, so the last one is drawn over the others.

Defaults and user settings

What you set in the attribute are defaults. The user can change the style, the width and the colors of every series in the settings of the indicator, and those choices are saved. Common styles: Line, Bars, Area, Range (two values per point), Candlestick (four values), and the markers Square, Cicle, Diamond, Cross, TriangleUp, TriangleDown. To read what the user chose, use GetSeries(definition):

Adding points

Add one point for every bar, in OnOpen:
The point of index i belongs to the bar of index i. Keep this true: add a point for every bar, hidden when it has no value yet. Then set the value where you calculate it:
Y has one value for most styles, two for Range (upper and lower), four for Candlestick (high, low, open, close).

Optional series

Set Enabled in OnSet to create a series only when a parameter asks for it:
A series which is not enabled has BaseSeries == null: check it before adding points.

Point options