The resource loading... loading...

Types of Interaction Controls

Variable (Name example) Description Type Default value (description) Component configuration (description) Remarks
cmdNum Description of interactive control cmdNum Number Default value is optional and can be left blank Used to set the interface controls bound to the current interactive item: component type, minimum value, maximum value, grouping, etc. Notes on the interactive control cmdNum
cmdBool Description of the interactive control cmdBool Boolean (true/false) Default value Required, on or off Same as above Notes on the interactive control cmdBool
cmdStr Description of the interactive control cmdStr String Default value is optional and can be left blank Same as above Notes on the interactive control cmdStr
cmdCombox Description of the interactive control cmdCombox Selected Default value is optional and can be left blank Same as above Notes on the interactive control cmdCombox
cmdBtn Description of the interactive control cmdBtn Button Button control is not bound to input item Same as above Notes on the interactive control cmdBtn

The message sent to the strategy after the interactive control is triggered (string): - Number After entering the interactive data “123” in the interactive control

"GetCommand()" function in the strategy program will receive the message
"cmdNum:123".
- Boolean
Set the switch control of the interactive control ```cmdBool``` to on, and
click the button of the interactive control cmdBool. The
```GetCommand()``` function in the strategy program will receive the
message: ```cmdBool:true```.
- String
After entering the interactive data: ```abc``` in the interactive
control ```cmdStr``` input box, click the interactive control cmdStr button.
The ```GetCommand()``` function in the strategy program will receive the
message: ```cmdStr:abc```.
- Selected
After selecting the second option in the drop-down box of the
interactive control cmdCombox, click the button of the interactive
control cmdCombox. The ```GetCommand()``` function in the strategy
program will receive the message: ```cmdCombox:1```, where 1 represents
the index of the selected option, the first option has an index of 0,
and the second option has an index of 1.
- Button
Click the button of the interactive control cmdBtn. The
```GetCommand()``` function in the strategy program will receive the
message: ```cmdBtn```.

Application of interactive controls: Dynamic modification of strategy parameters
For example, the strategy has a parameter called symbol. The strategy parameters added on the strategy interface are also global variables, so the global variables in the code are used here as a demonstration.

```js
// Strategy parameters
var symbol = "BTC_USDT"

function main() {
    while (true) {
        var cmd = GetCommand()
        if (cmd) {
            var arr = cmd.split(":")
            if (arr.length == 2 && arr[0] == "changeSymbol") {
                // When the changeSymbol control is detected, the parameter update operation will be performed
                Log("Modify the symbol parameter to:", arr[1])
                symbol = arr[1]
            }
        }
        
        LogStatus(_D(), ",The current symbol parameter values are:", symbol)
        Sleep(3000)
    }
}

Set up interactive controls: image

Strategy Parameters Component Configuration