Strategy Parameters
Parameters configured in the strategy interface exist as global variables in the strategy code. JavaScript, C++, and MyLanguage strategy code can directly access and modify parameter values set in the strategy interface. Python strategies need to use the global keyword when modifying global variables or strategy interface parameters within functions. PINE language uses the input() function to create interface parameters. Strategies designed using Blockly Visual mode do not support interface parameters.

Interface Parameter Types
| Variable (naming example) | Description | Type | Default Value (description) | Component Configuration (description) | Remarks |
|---|---|---|---|---|---|
| pNum | Description of parameter pNum | Numeric (number) | Example: Set default value to 100, floating point type in C++ strategies | Used to set the interface control bound to the current parameter: component type, minimum value, maximum value, grouping, filters, etc. | Remarks for parameter pNum, the value of pNum is numeric type |
| pBool | Description of parameter pBool | Boolean (true/false) | Use switch control to set default value, optional control not supported | Same as above | Remarks for parameter pBool, the value of pBool is boolean type |
| pStr | Description of parameter pStr | String (string) | Example: Set default value to abc | Same as above | Remarks for parameter pStr, the value of pStr is string type |
| pCombox | Description of parameter pCombox | Dropdown (selected) | Set one or more options from the options | Same as above | Remarks for parameter pCombox, the value of pCombox may have various forms |
| pSecretStr | Description of parameter pSecretStr | Encrypted string (string) | Example: Set default value to xyz | Same as above | Remarks for parameter pSecretStr, the value of pSecretStr is string type |
Interface parameters are configured in the strategy parameters area below the code editor on the strategy editing page. Please note the following:
- In the default value option of parameter settings, the "Optional" control is optional by default. You can change the state of this control to set the current parameter as required. After setting a parameter as required, if the parameter is not set during backtesting or live trading, backtesting cannot be performed or live trading cannot be started.
- Variable names for interface parameters in strategy code should not use reserved words (keywords) of the current programming language.
- In the backtesting or live trading interface, hovering the mouse over the control bound to a parameter will display the parameter's remarks.
- The "Description" of a parameter is the display name of the control bound to the parameter.
- The "Variable" of a parameter refers to those in the table above:
pNum,pBool,pStr,pCombox,pSecretStr. They exist as global variables in the strategy code, so the values of strategy parameters can be modified in the code. - For "Encrypted string" and "String" type parameters, no quotes are needed when entering default values; all input is treated as strings. "Encrypted string" parameters are used the same way as "String" parameters, but encrypted strings are transmitted encrypted and not sent in plain text.
- If a "String" type parameter is set to "Optional", when no parameter is filled in the control bound to the parameter, the value of the parameter variable is empty string;
Similarly, the value of a "Numeric" parameter is null;
Similarly, the value of a "Dropdown" parameter is null;
Similarly, the value of an "Encrypted string" parameter is null. - For dropdown type interface parameters (e.g., variable name
pCombox), when "Support multiple selection" is not enabled in "Component Configuration", the value of pCombox is the index or specific data of the currently selected option (when data is bound to options).
If "Support multiple selection" is enabled, the value of pCombox is an array containing the indices or specific data of all currently selected options (when data is bound to options).
Component Configuration
The "Component Configuration" option for strategy interface parameters is used to set controls corresponding to 5 parameter types on the platform, enhancing functionality and simplifying design.
Supported component types for the 5 interface parameters:
- Number type parameters
Supported component types: Input box control (default), Time picker control, Slider control. - Boolean (true/false) parameters
Only supports switch control (default). - String parameters
Supported component types: Input box control (default), Text box control, Time picker control, Color picker control, Currency selector, Trading code selector. - Dropdown (selected) parameters
Supported component types: Dropdown control (default), Segmented control, Currency selector, Trading code selector. - Encrypted string parameters
Only supports encrypted input box control (default).
In addition to setting the control types for interface parameters, you can also set grouping and filtering for interface parameters.
- Grouping
In the "Group" input box of component configuration, you can enter a label name to group several strategy interface parameters under the same group label (replacing the platform's old "Strategy Grouping" feature). - Filter
In the "Filter" input box of component configuration, you can enter filter condition expressions to control whether interface parameters take effect (replacing the platform's old "Parameter Dependency" feature).
The filter is empty by default, with no parameter condition filtering; you can set:a > b,a == 1,a,!a,a >= 1 && a <= 10,a > b, etc. When the filter condition is true, the current parameter is available.- When a parameter has filter
a == 1set, the availability of this parameter depends on the value of parametera. When parameteraequals 1, this parameter is available; otherwise, it is unavailable. - When a parameter has filter
a >= 1 && a <= 10set, it means the filter condition is: a is greater than or equal to 1 and a is less than or equal to 10. When this condition is met, the parameter is available; otherwise, it is unavailable. - When a parameter has filter
!aset, it means the filter condition is: not a; a can be a boolean value or a numeric value (!0 represents true).
- When a parameter has filter
Save Parameter Settings
-
Parameter Saving in Backtesting System
When backtesting, if you want to save strategy parameters, you can click the "Save Backtest Settings" button after modifying strategy parameters. For details, please refer to the Backtesting System "Save Backtest Settings".Variable Description Type Default Value number Numeric Type Number 1 string String String Hello FMZ combox Dropdown Dropdown (selected) 1|2|3 bool Boolean Boolean (true/false) true numberA@isShowA Number A Number 2 isShowA Show numberA parameter Boolean (true/false) false The configured strategy parameters will be saved in the strategy as code, for example:
javascript/*backtest start: 2020-02-29 00:00:00 end: 2020-03-29 00:00:00 period: 1d args: [["number",2],["string","Hello FMZ.COM"],["combox",2],["bool",false],["numberA@isShowA",666],["isShowA",true]] */python'''backtest start: 2020-02-29 00:00:00 end: 2020-03-29 00:00:00 period: 1d args: [["number",2],["string","Hello FMZ.COM"],["combox",2],["bool",false],["numberA@isShowA",666],["isShowA",true]] '''c++/*backtest start: 2020-02-29 00:00:00 end: 2020-03-29 00:00:00 period: 1d args: [["number",2],["string","Hello FMZ.COM"],["combox",2],["bool",false],["numberA@isShowA",666],["isShowA",true]] */ -
Live Trading Parameter Import/Export
When running live trading, if you need to save the parameter data of live trading configuration, you can click the "Parameter Settings" option on the strategy live trading page, then click the "Export Parameters" button. The exported strategy parameters will be saved injsonfile format.
The exported strategy parameter configuration can be imported into live trading again. Click the "Import Parameters" button to import the saved strategy live trading parameters into the current live trading. After importing, click the "Update Parameters" button to make the configuration take effect.