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

Sway Charts Pro Framework

Previous9.3 Multi-timeframe (MTF) indicatorsNextExamples

Last updated 1 year ago

You can use the Sway Charts Pro framework to build trading algos, indicators for charts, and whole new tools within the Sway Charts Pro platform.

The Sway Charts Pro framework provides three types of software development:

· Widgets. All the built-in tools in Sway Charts Pro – charts, quote board, trade list etc – are widgets, and any widgets which you create have access to all the same features as built-in widgets.

· Scripts. You can create and save scripts using the Run Script widget in Sway Charts Pro. Scripts can be given icons in the platform's banner, and can be set to start automatically when the platform is loaded. (Scripts can also be given a context, so that they are available in specific places within the Sway Charts Pro platform.)

· User-defined indicators, for charts.

User-defined indicators subdivide into two types:

· Standard indicators (UDI), which only have access to the chart on which they run.

· Enhanced indicators (UDIX) which also have access to the Sway Charts Pro framework described here. They can see data such as the trade list, and they can carry out actions such as placing trades.

Creating indicators is described elsewhere, at . A UDIX is simply an indicator which also has a Framework object, in addition to the indicator features which are described separately. You choose whether to give a UDI access to the Framework, turning it into a UDIX, when you add it to a chart.

In terms of the web browser:

· Widgets are iframes (sandboxed). A widget is simply an HTML document which integrates with Sway Charts Pro by including the framework script and CSS.

· Scripts and UDIXes are web workers. They have no user interface of their own, but they can create dialogs and interact with the platform.

Sway Charts Pro is a web-based platform, and therefore the programming language for creating widgets, scripts, and UDIXes is simply Javascript. You can also write your code in any language such as TypeScript or CoffeeScript which compiles to Javascript.

You can use any development environment, from Notepad to Visual Studio or Eclipse. You can paste HTML/Javascript into the Run Script and External Widget windows in Sway Charts Pro. You don't have to write your code inside the Sway Charts Pro platform.

Note: in addition to the facilities described here for extending the Sway Charts Pro platform, it is also possible to use the Excel RTD widget to write code outside the Sway Charts Pro platform, in any language of your choice such as Node.js, C#, or Python, communicating with the web browser using HTTP or websockets. It is even possible to download data directly into Excel without any programming. For more information, see the document about the Excel RTD widget:

https://www.fxblue.com/Sway Charts Pro/udi/help
https://www.fxblue.com/Sway Charts Pro/excel-rtd/help