Sway Charts Pro Scripts Documentation
  • Sway Charts Pro User-Defined Indicators
    • Introduction
      • 1.1 Access to the Sway 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
  • Sway 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
    • Sway.utils and other helper functions
    • Framework error codes
    • Script contexts
    • Sending mail into Sway Charts Pro from outside the platform
    • language variables
Powered by GitBook
On this page
  1. Sway Charts Pro User-Defined Indicators
  2. Initialisation: UDI.onInit()

2.1 Return value from UDI.onInit()

The return value from UDI.onInit() should be an object, as in the example above, with the following members:

Member

Description

caption

The name to display for your UDI

isOverlay

True/false depending on whether your UDI should be shown in the main chart panel (true) or in its own sub-panel (false)

plots[]

Array describing the types of values which your UDI draws: lines, histograms, bars etc. The array can be empty if your UDI only creates drawings, or event markers, or bar highlights.

settingsFields[]

Array of user-configurable parameters which your UDI wants. This array can be empty if your indicator does not need any configurable settings.

noAlerts

Can be used to turn off the ability for the user to set alerts on any of the UDI's plots. You can also disable this for each individual plot, using its own noAlerts property.

noIOI

Can be used to prevent your UDI participating in the ability to apply one indicator to another indicator.

axis

Overrides the default settings for the value axis, by including any or all of the following properties. Only applicable if the indicator is in its own sub-panel (isOverlay:false).

axis.min

Minimum value for the axis

axis.max

Maximum value for the axis

axis.step

Increment between markers on the axis

axis.noYGrid

Turns off horizontal grid lines in the sub-panel

axis.baseline

Baseline value (which turns a line plot into a filled area either side of the baseline)

PreviousInitialisation: UDI.onInit()Next2.2 The plots[] array

Last updated 1 year ago