Declaring a series
A series is declared in two parts: an attribute class with its defaults, and a property which holds it.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, inOnOpen:
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
SetEnabled in OnSet to create a series only when a parameter asks for it:
BaseSeries == null: check it before adding points.