Liquid Charts API Docs
Liquid Charts Pro Scripts Documentation
Liquid Charts Pro Scripts Documentation
  • Liquid Charts Pro User-Defined Indicators
    • Introduction
      • 1.1 Access to the Liquid Charts scripting framework (UDI vs UDIX)
      • 1.2 Example UDI code
      • 1.3 Adding a UDI to a chart
      • 1.4 Lifecycle
      • 1.5 Alerts
      • 1.6 Indicator-on-indicator
      • 1.7 Technical note: web workers
      • 1.8 Technical note: dates
    • Initialisation: UDI.onInit()
      • 2.1 Return value from UDI.onInit()
      • 2.2 The plots[] array
      • 2.3 The settingsFields[] array
      • 2.4 Context data passed to UDI.onInit()
    • Calculating data: UDI.onCalculate()
      • 3.1 Reading settings fields
      • 3.2 Input data for the UDI
      • 3.3 Updates of the current bar only
      • 3.4 Calculating output data
      • 3.5 Requesting out-of-band updates
      • 3.6 Technical analysis: moving averages, ATR etc
    • Changes to the chart or parameters
      • 4.1 UDI.onContextChange()
      • 4.2 UDI.onParameterChange()
    • Creating drawings, event markers, and bar highlights
      • 5.1 Creating drawings
      • 5.1.1 Drawing properties
      • 5.2 Creating event markers
      • 5.2.1 Click notifications from event markers
      • 5.3 Creating bar highlights
    • Notifying the user
      • 6.1 Creating toast
      • 6.2 Changing the panel background colour
    • Adding HTML to the chart
      • 7.1 Adding HTML
      • 7.2 Positioning the HTML
      • 7.3 Sending messages from the HTML to the UDI
      • 7.4 Sending messages from the UDI to the HTML
    • Recommended trade
      • 8.0 Recommended trade
    • Other indicator topics
      • 9.1 Collecting external data
      • 9.2 Converting dates to chart time
      • 9.3 Multi-timeframe (MTF) indicators
  • Liquid Charts Pro Framework
    • Examples
    • Collections, objects, and properties in the framework
    • Functions in the framework
    • Messages and event handlers
    • Working with candle data
    • Widget HTML and CSS reference
    • Liquid.utils and other helper functions
    • Framework error codes
    • Script contexts
    • Sending mail into Liquid Charts Pro from outside the platform
    • language variables
Powered by GitBook
On this page
  1. Liquid Charts Pro User-Defined Indicators
  2. Initialisation: UDI.onInit()

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.)

settingsFields: [
	{id: "Source"}
	…
]

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:

settingsFields: [
	{id: "Source"},
	{id: "threshold", caption: "Threshold", type: "float", defaultValue: 1, min: 1, step: 0.1},
	{id: "highlightcolor", caption: "Color", type: "color", defaultValue: "rgba(0,0,255,0.5)"},
	{id: "options", caption: "Display type", type: "select", options: [
		{k: "line", v: "Display as line"},
		{k: "marker", v: "Display as histogram"}
	]}
]

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 Liquid.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.

Previous2.2 The plots[] arrayNext2.4 Context data passed to UDI.onInit()

Last updated 3 months ago