Interface Parameter Types
Interface parameters are set in the strategy parameters area below the code editor on the strategy editing page. There are 5 types; the variable names in the table are only examples:
| Type | Example variable | Value in code | Default value |
|---|---|---|---|
| Number (number) | pNum | A number; f64 in Rust | Enter a number, e.g. 100 |
| Boolean (true/false) | pBool | A boolean | Set with a switch; cannot be optional |
| String (string) | pStr | A string | Type it as is, e.g. abc, without quotes |
| Dropdown (selected) | pCombox | Index or bound data of the selected option; an array with multiple selection | Select one or more options |
| Encrypted string (string) | pSecretStr | A string | Type it as is, e.g. xyz, without quotes |
Settings of a parameter
- Variable: the name of the parameter's global variable in the strategy code; do not use a reserved word (keyword) of the programming language.
- Description: the display name of the control bound to the parameter.
- Remarks: the tooltip shown when the mouse hovers over the parameter's control in the backtest or live robot interface.
- Default value and "Optional": the "Optional" switch next to the default value is on by default and can be turned off to make the parameter required. A backtest or live robot cannot start if a required parameter is not set.
- Component configuration: the type of UI control bound to the parameter, plus minimum, maximum, group, filter and so on; see
Component Configuration.
Notes
- Parameters are global variables in the code and can be modified there (except in Rust, where parameters are global constants and cannot be modified).
- An "Encrypted string" parameter is used the same way as a "String" parameter, but it is sent encrypted, never in plain text.
- An optional parameter that is left empty is an empty string for String parameters, and a null value for Number, Dropdown and Encrypted string parameters. In
Ruststrategies it is the zero value of its type:0for numbers, an empty string for strings and encrypted strings,falsefor booleans. - A dropdown parameter without "Support multiple selection" in its component configuration holds the index of the selected option, or the option's bound data if data is bound; with "Support multiple selection" it holds an array of the indices (or bound data) of all selected options.