Type/to search
Built-in Functions
Structures
Trade
Ticker
Record
Order
Condition
OrderBook
Depth
Account
Asset
Position
Market
Funding
OtherStruct
HttpQuery-options
HttpQuery-return
LogStatus-table
LogStatus-btnTypeOne
LogStatus-btnTypeTwo
Chart-options
KLineChart-options
SetData-data
EventLoop-return
DBExec-return
Thread.join-return
Built-in Variables

This JSON structure is used to configure button controls in the status bar. The button control JSON structure can be embedded into the status bar table JSON structure. This is a legacy version structure that the platform still supports for compatibility, but it is recommended to use the latest version of the button JSON structure.
Status bar button control construction example (after button click trigger, the popup contains a single input control, constructed through the input field):

json
{ "type": "button", "cmd": "open", "name": "Open Position", "input": { "name": "Position Size", "type": "number", "defValue": 1 } }

The controls in the popup triggered by clicking the status bar button are configured through the input or group fields.

Attributes

NameTypeDescription

type

string

For button controls, fixed as: button.

class

string

Button type setting.

name

string

The text displayed on the button control, i.e., the button name.

cmd

string

The interactive command content sent to the strategy when the button control triggers a click operation.

description

string

Description information for the button control. This description is displayed when the mouse hovers over the button in the status bar.

disabled

bool

Set the button as disabled (true) or enabled (false).

input

JSON

When constructing status bar buttons for interaction, data input is supported. The interaction command is ultimately captured by the GetCommand() function. Add an input item to the JSON data structure of the status bar button control to configure the input control in the popup displayed when the button is triggered.
For example, set the input field value to:

json
{ "name": "Position Size", "type": "number", "defValue": 1, "description": "test" }

Description of each field in the above JSON structure:

  • name
    The title of the control in the popup that appears after the status bar button is clicked.
  • description
    The description information of the control in the popup that appears after the status bar button is clicked.
  • type
    The type of control in the popup that appears after the status bar button is clicked. The type field can take the following values:
    1. "number": Numeric input control.
    2. "string": String input control.
    3. "selected": Dropdown control.
    4. "boolean": Switch control.
  • defValue
    The default value of the control in the popup that appears after the status bar button is clicked.
    For dropdown type controls (selected), the defValue field is used to set dropdown options, for example: "input": {"name": "Position Size", "type": "selected", "defValue": "A|B|C"}, the text descriptions of the dropdown options are set to A, B, C.

Extended fields for dropdown type controls:

  • options
    For dropdown controls in the page triggered by status bar button controls, the options field can be used to set options. Options in the options field support not only strings but also the {text: "description", value: "value"} structure. Use the defValue field to set default options, which can be multiple selections.
  • multiple
    When this field is set to true, the dropdown supports multiple selections.

group

array

The input field configures a single control in the popup that appears after the status bar button is clicked, while the group field is used to configure a group of controls. The data structure of elements in group is consistent with the value of the input field. Please refer to the related description of the input field.

See Also

Remarks

Example of class attribute values for button JSON structure in status bar:

javascript
function main() { var table = { type: "table", title: "Status Bar Button Styles", cols: ["Default", "Primary", "Success", "Info", "Warning", "Danger"], rows: [ [ {"type":"button", "class": "btn btn-xs btn-default", "name": "Default"}, {"type":"button", "class": "btn btn-xs btn-primary", "name": "Primary"}, {"type":"button", "class": "btn btn-xs btn-success", "name": "Success"}, {"type":"button", "class": "btn btn-xs btn-info", "name": "Info"}, {"type":"button", "class": "btn btn-xs btn-warning", "name": "Warning"}, {"type":"button", "class": "btn btn-xs btn-danger", "name": "Danger"} ] ] } LogStatus("`" + JSON.stringify(table) + "`") }

group field and input field usage example:

javascript
function main() { // Status bar button control (implemented with input field) - The dropdown control on the page triggered by testBtn1 button uses options field to set options and defValue field to set default option. This differs from other examples in this chapter that directly use defValue to set options. var testBtn1 = { type: "button", name: "testBtn1", cmd: "cmdTestBtn1", input: {name: "testBtn1ComboBox", type: "selected", options: ["A", "B"], defValue: 1} } /* Status bar button control (implemented with input field) - The dropdown control on the page triggered by testBtn2 button uses options field to set options. The options field supports not only strings, but also ```{text: "description", value: "value"}``` structure. Use defValue field to set default option, which can be multiple selections (implemented through array structure). Multiple selection requires setting additional field multiple to true. */ var testBtn2 = { type: "button", name: "testBtn2", cmd: "cmdTestBtn2", input: { name: "testBtn2MultiComboBox", type: "selected", description: "Implement dropdown multi-select", options: [{text: "Option A", value: "A"}, {text: "Option B", value: "B"}, {text: "Option C", value: "C"}], defValue: ["A", "C"], multiple: true } } // Status bar grouped button control (implemented with group field) - The dropdown control on the page triggered by testBtn3 button uses options field to set options, and also supports directly using defValue to set options. var testBtn3 = { type: "button", name: "testBtn3", cmd: "cmdTestBtn3", group: [ {name: "comboBox1", label: "labelComboBox1", description: "Dropdown 1", type: "selected", defValue: 1, options: ["A", "B"]}, {name: "comboBox2", label: "labelComboBox2", description: "Dropdown 2", type: "selected", defValue: "A|B"}, {name: "comboBox3", label: "labelComboBox3", description: "Dropdown 3", type: "selected", defValue: [0, 2], multiple: true, options: ["A", "B", "C"]}, { name: "comboBox4", label: "labelComboBox4", description: "Dropdown 4", type: "selected", defValue: ["A", "C"], multiple: true, options: [{text: "Option A", value: "A"}, {text: "Option B", value: "B"}, {text: "Option C", value: "C"}, {text: "Option D", value: "D"}] } ] } while (true) { LogStatus("`" + JSON.stringify(testBtn1) + "`\n", "`" + JSON.stringify(testBtn2) + "`\n", "`" + JSON.stringify(testBtn3) + "`\n") var cmd = GetCommand() if (cmd) { Log(cmd) } Sleep(5000) } }