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

Creating drawings, event markers, and bar highlights

In addition to plotting values, using the plots[] array and UDI.onCalculate(), your UDI can also create objects on the chart:

· Drawings, such as rectangles, lines, bar markers, trend channels etc

· Event markers. These are markers against a specific date/time, displayed at the bottom of the chart, and automatically stacked if there are multiple markers to be displayed against the same bar.

· Bar highlights. These change the colour of a specific bar on the chart in order to highlight it.

Note: you cannot create these objects from UDI.onInit(). If you want to create objects on start-up, do so from the first call to UDI.onCalculate() which is always issued immediately after an indicator is loaded.

For examples of the event markers and bar highlights, see the built-in Inside Bars or Outside Bars indicators.

When you create one of these objects, it stays on the chart (until your UDI is removed). You do not need to re-create the object in each call to UDI.onCalculate().

Objects are not removed if the user changes the market or timeframe of a chart. You will often want to remove and re-create objects after this sort of change, which you can detect using UDI.onContextChange().

Objects can be created from any function in your UDI, not just in response to UDI.onCalculate(). For example, you can use XMLHttpRequest to get external data, and then display that data on the chart as drawings:

UDI.onInit = function(data)
{
	// Make a data request 
	var xmlr = new XMLHttpRequest();
	xmlr.addEventListener("load", onMyDataLoad);
	xmlr.open("GET", "http://www.example.org/mydata");
	xmlr.send();

	// Return indicator definition
	return { … };
}

function onMyDataLoad()
{
	// Parse this.responseText and create objects…
	UDI.createDrawing(…);
}

Your UDI cannot see or manipulate objects which do not belong to it. You cannot modify or remove drawings, event markers, or bar highlights which were created by the user or by another indicator.

Previous4.2 UDI.onParameterChange()Next5.1 Creating drawings