Supported types
Layout
Three attributes control how a parameter appears:[Category("General")]fromSystem.ComponentModelputs it in a section.[DisplayName("Price source")]gives it a label. Without it, the name of the property is used.[VolCustom(...)]fromVolumetricaControlssets the order and the limits.
VolCustom:
Nested objects
A parameter can be a class with its own properties. The settings window shows it as a group:Properties that are not parameters
- A property without a public setter is not a parameter. The series definitions use this:
public ChartSeriesDefinition Average { get; private set; }. - Fields are never parameters: keep the state of the calculation in fields.
The names of the properties are what the workspace saves. Renaming a property loses the value the user saved for it. A property you remove is ignored when a workspace saved before is loaded.
Reading the parameters
Read them wherever you need: they are set beforeOnSet. When the user changes one, the chart calls OnSet again and recalculates the indicator, so the calculation never has to watch for changes.
Parameters resolved by the chart
A parameter your code reads changes the calculation: when the user changes it, the indicator is calculated again. A parameter which only changes how something looks does not need that. Declare it with one of these types and assign it as it is:LevelWidth”, not its value: the chart of each user resolves it with what that user has set. For an indicator calculated on the server, a change of one of these parameters is applied at once, without a new calculation.
Rules:
- Assign it, do not use it in the calculation. On the server these parameters always hold their default.
LevelWidth * 2,LastLevels - 1andShowLevels.Valuecompile, and on the server they give the default.if (ShowLevels)does not compile, on purpose. - With a condition, keep the reference:
levels.Visible = inRange ? ShowLevels : false; - Give it the meaning and the range of what it is assigned to. The chart uses the value of the user as it is:
-1inMaxCountShownis no limit,100inWithOpacityScaleleaves the opacity as it is. SetMinValueandMaxValueto match. - When a flag decides what is calculated, it is a plain
bool. - Always draw the group. A hidden group is still calculated and sent: that is what makes the switch immediate.
int that becomes a PlotIntRef, a number that becomes a LineWidthRef, a DashStyle that becomes a LineStyleRef, a bool that becomes a PlotBoolRef.
What a group does with Visible, PlotForeground and MaxCountShown is in Annotations. The changes of a color bound to a parameter are in Colors.