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. Recommended trade

8.0 Recommended trade

Indicators can use the UDI.setRecommendedTrade() function to set a "recommended trade", signalled to the user by a lightning-bolt icon next to the name of the indicator on the chart. Clicking on the icon then fills the recommendation into the chart's deal ticket, ready for placement.

Note: this functionality is not available in older versions of the platform. To avoid run-time errors, you should check for its availability before trying to use it:

if (UDI.setRecommendedTrade) {

// Function(ality) is available…

}

You can pass three types of parameter to UDI.setRecommendedTrade():

Null. Hides the icon.

An empty object, {}. Icon is visible, but disabled and greyed-out.

A partial or full trading definition.

A trading definition is fundamentally the same as the parameter for SendOrder() in the Figaro framework. The major difference is that UDIs do not have access to the Liquid.OrderTypes enumeration. You specify the order type using the textual name from the enumeration, such as "SELL_LIMIT", rather than a constant such as Liquid.OrderTypes.SELL_LIMIT. For example:

UDI.setRecommendedTrade({

tradingAction: "SELL_LIMIT",

openPrice: 1.07,

sl: 1.08,

tp: 1.06,

comment: "My indicator"

});

Although your definition should always include a tradingAction, all the properties of the definition are optional rather than compulsory. The deal ticket will only update with the properties which you include. For example, if you do not include a tp then the take-profit field in the deal ticket will be unchanged, and will continue to use/show any previous value set by the user. Therefore, if you specifically want to recommend an order with no take-profit, you should set tp:0 rather than omitting the tp property.

Your definition can use all the derived properties which are accepted by SendOrder(). For example, you can use the following to set the stop-loss at 20 pips from the entry price, varying tick by tick while the deal ticket is open:

UDI.setRecommendedTrade({

tradingAction: "BUY",

sl: {pips: 20},

tp: 0

});

It is up to you whether you set a trading volume in your definition, or whether you omit it and leave the volume at the most recent value set by the user. If you do set a trading volume then it is most common to use a risk-based value (in combination with a stop-loss), rather than an absolute quantity. For example, volume: {equityPercent: 1}.

PreviousRecommended tradeNextOther indicator topics

Last updated 3 months ago