bindingInfo.setCandleBindingField(arr)

bindingInfo.getCandleBindingField(measure) to obtain existing binding information.

Configure the binding for a Candle Chart. A candlestick chart displays four different measures, “low,” “high,” “opening,” and “closing,” and is most often used to plot trading information.

Parameter

arr

Array of properties for a candle chart measure:

[field1,measure,formula,option,field2]

The items in the array are described below:

field1

Field containing data corresponding to measure.

measure

The measure represented by field1:

Chart.HIGH   // field1 defines the high values
Chart.LOW:   // field1 defines the low values
Chart.OPEN:  // field1 defines the opening values
Chart.CLOSE: // field1 defines the closing values
formula

Summarization Formula constant (optional)

option

Specifies how percentages should be computed (optional):

Chart.PERCENTAGE_NONE
Chart.PERCENTAGE_OF_GRANDTOTAL
Chart.PERCENTAGE_OF_GROUP
field2

Optional second operand for a bivariate formula (e.g., correlation).

Example

To create a candle chart that displays the average high, low, opening, and closing prices by quarter, follow the steps below:

  1. Create a new Dashboard. (See Create a New Dashboard.)

  2. Select the ‘Stock Prices’ query as the data source.

    The 'Stock Prices' Data Worksheet can be found in Data Worksheet  Examples. You may need to download the examples.zip file from GitHub into your environment. (This requires access to Enterprise Manager.) See Import and Export Assets for instructions on how to import.
  3. Add a new Chart component.

  4. Enter the following script in the onRefresh handler of the Dashboard.

    Chart1.query='Stock Prices';
    Chart1.chartStyle = Chart.CHART_CANDLE;
    var data_high = ["Stock Prices.High",Chart.HIGH,Chart.AVERAGE_FORMULA];
    var data_low = ["Stock Prices.Low",Chart.LOW,Chart.AVERAGE_FORMULA];
    var data_close = ['Stock Prices.Close/Last',Chart.CLOSE,Chart.AVERAGE_FORMULA];
    var data_open = ['Stock Prices.Open',Chart.OPEN,Chart.AVERAGE_FORMULA];
    Chart1.bindingInfo.xFields=[['Date',Chart.DATE]];
    Chart1.bindingInfo.setGroupOrder('Date',Chart.QUARTER_INTERVAL);
    
    Chart1.bindingInfo.setCandleBindingField(data_high);
    Chart1.bindingInfo.setCandleBindingField(data_low);
    Chart1.bindingInfo.setCandleBindingField(data_close);
    Chart1.bindingInfo.setCandleBindingField(data_open);
    Dashboard script that modifies bindingInfo should generally be placed in the onRefresh handler. See Add Dashboard Script.
  5. Press the ‘Preview’ button preview to preview the chart.

    setCandleBinding2

    You can also use the ‘Zoom In’ button zoom in to limit the date range.
  6. To observe the structure of the Chart more closely, set a condition on the chart to limit the date range (e.g., limit to the year of 2004).

    setCandleBinding3

Note that for each quarter, the values of each of the measures (High, Low, Close/Last, Open) have been independently aggregated as specified by the corresponding formula parameter (in this case, Chart.AVERAGE_FORMULA for each). The “high” and “low” measures are represented by the extremes of the vertical line, and the “open” and “close” measures are represented, respectively, by the left and right horizontal lines.

Typically, different formulas are used for the different measures. For example, max for the "high", min for the "low", first for the open, and last for the close. See Candle Chart for an example that uses this approach.