In the trading strategy codes, the strategy parameters set on the strategy interface are reflected in the form of global variables. In the strategy code of JavaScript
, C++
, MyLanguage
can directly access the parameter values set or modified the parameters on the strategy interface. In the functions of Python
strategies, the keyword global
is needed to modify the global variables and strategy interface parameters. The PINE
language uses the input()
function to create interface parameters. The Blockly visualization
approach designs strategies without interface parameters.
Variable (Name example) | Description | Type | Default value (description) | Component configuration (description) | Remarks |
---|---|---|---|---|---|
- | - | - | - | - | - |
pNum | Description of parameter pNum | number | For example, set the default value to 100, which is a floating point type in C++ strategy. | Used to set the current parameter binding interface controls: component type, minimum value, maximum value, grouping, filter, etc. | Remarks on parameter pNum. The value of pNum is a numeric type. |
pBool | Description of parameter pBool | true/false | Use a switch control to set a default value, without an optional control | The same as above | Remarks on parameter pBool. The value of pBool is of Boolean type. |
pStr | Description of parameter pStr | string | For example, set the default value to: abc | The same as above | Remarks on parameter pStr, the value of pStr is a string type |
pCombox | Description of parameter pCombox | selected | Set one or more options in the options | The same as above | Remarks on parameter pCombox. The value of pCombox may take many forms. |
pSecretStr | Description of parameter pSecretStr | string | For example, set the default value to: xyz | The same as above | Remarks on parameter pSecretStr. The value of pSecretStr is a string type. |
Interface parameters are set in the strategy parameter area below the code editing area on the strategy editing page. Please note:
pNum
, pBool
, pStr
, pCombox
, pSecretStr
. It exists in the strategy code as a global variable, which means that the strategy parameters can be modified in the code.pCombox
. When “Support multiple selections” is not enabled in “Component Configuration”, the value of pCombox is the index of the currently selected option or the specific data (when data is bound to the option).
If “Support multiple selections” is enabled, the value of pCombox is an array containing the indexes or specific data (when binding data to the options) of all currently selected options.The “Component Configuration” option of the strategy interface parameters is used to set controls corresponding to the 5 parameter types on the platform, enhancing functionality and simplifying design.
5 types of components supported by interface parameters:
In addition to setting the control type corresponding to the interface parameters, you can also set the grouping and filtering of the interface parameters.
Parameter saving in the backtesting system
If you wish to save the strategy parameters during backtesting, you can click the Save Backtest Settings
button after the strategy parameters are modified, refer to the backtesting system Save Backtest Settings.
Variables | Description | Type | Default Value |
---|---|---|---|
number | Numeric type | Number | 1 |
string | Numeric type | String | Hello FMZ |
combox | ComboBox | ComboBox (selected) | 1|2|3 |
bool | Boolean value | Boolean (true/false) | true |
numberA@isShowA | Number A | Number | 2 |
isShowA | Whether to display the parameter numberA | Boolean (true/false) | false |
You can save the strategy parameter settings in form of code, for example:
/*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]]
*/
'''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]]
'''
/*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]]
*/
Living Trading Parameters Import & Export
When running the live trading, you need to save the parameter data of the live trading configuration, you can click the “Export” button. The exported strategy parameters will be saved in the json
file.
The exported strategy parameter configuration can also be imported to the living trading again. Click the “Import” button to import the saved strategy live trading parameters to the current live trading. Then, click “Save” to save.