2.3 The settingsFields[] array
The settingsFields[] array in the object you return from UDI.onInit() describes the configurable fields which people should be able to modify for your indicator.
There is one special field which fundamentally affects the type and behaviour of your UDI. If your indicator has a Source field then it receives, in UDI.onCalculate(), a single data series such as the close prices or the high prices – or the values from another indicator. If your indicator does not have a Source field then it receives the full data for each bar – open, high, low, close, and volume – and your UDI cannot be applied to another indicator.
The Source field is defined in the settingsFields[] array as follows. (It is normal, but not compulsory, for it to be the first field.)
All other fields in the settingsFields[] array should have an id, a caption, and a type. They can also optionally have other properties depending on the type of field. For example:
The types of field which you can use are as follows:
Field type | Description |
int | Integer field |
float | Numeric, non-integer field |
yesno | Yes/no (Boolean) field |
select | List of options |
textline | Free-text field |
color | Colour field |
maType | Type of moving average, for use with the SWay.ta library |
The full set of properties which can be defined for each field is as follows:
Property | Description |
id | ID for your field |
caption | Display text for your field |
type | The type of field: "int", "color", "textline" etc |
defaultValue | Default value for the field (depending on its type) |
omitFromParameters | Tells the chart that the field should not be displayed in the summary of the indicator's values |
min | For numeric fields, the minimum value which can be entered |
max | For numeric fields, the maximum value which can be entered |
step | For numeric fields, the increment between values |
options[] | For the select field-type only, an array of options for the user to select from. Each entry in the array should have a key, k, and a displayable caption, v. For example: {k: "close", v: "Close price"}. The value which your indicator receives, in UDI.onCalculate(), is the k property. |
Last updated