资源加载中... loading...

Strategy Parameters

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. Strategy parameter setting interface

Interface Parameter Types

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:

  1. In the default value option of parameter setting, the “optional” control is in the optional state by default. You can change the state of this control and set the current parameter as required. After setting the parameter default value as required, if the strategy does not set this parameter during backtesting/live trading, backtesting/live trading cannot be started.
  2. The variable name of the interface parameter in the strategy code should not be set to the reserved word (keyword) of the current programming language.
  3. When the mouse is placed on the control bound to the parameter in the backtest/live trading interface, the set parameter note information will be displayed.
  4. The “description” of the parameter is the display name of the control to which the parameter is bound.
  5. The “variable” of the parameter is as shown in the table above: 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.
  6. For parameters of type “encrypted string” and “string”, the default value does not need to be quoted when input, and the input is processed as a string. The use of the “encrypted string” parameter is the same as that of the “string” parameter. The encrypted string will be sent encrypted and will not be transmitted in plain text.
  7. If a parameter of type “string” is set to “optional”, when the parameter is not filled in the control to which the parameter is bound, the value of the parameter variable is empty string; Similarly, if it is a parameter of “Nmber”, the value of the parameter variable is null value. Similarly, if it is a parameter of “Selected box”, the value of the parameter variable is null value. Similarly, if it is a parameter of “Encrypted string”, the value of the parameter variable is null value.
  8. For interface parameters of the selected type, for example, the variable name is 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.

Component Configuration

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:

  • Number parameters Supported component types: input box control (default), time selector control, and sliding input bar control.
  • Boolean (true/false) parameters Only switch controls are supported (default).
  • String parameters Supported component types: input box control (default), text box control, time selector control, color selector control, currency, and trading code.
  • Selected parameters Supported component types: drop-down box control (default), segment controller control, currency, and trading code.
  • String parameters Only supports encrypted input box controls (default).

In addition to setting the control type corresponding to the interface parameters, you can also set the grouping and filtering of the interface parameters.

  • Grouping In the “Group” input box of the component configuration, you can enter a name for a label to group several strategy interface parameters into a group label (replacing the platform’s old function “Strategy Grouping”).
  • Filter In the “Filter” input box of the component configuration, you can enter the filter judgment expression to control whether the interface parameters are effective (replacing the platform’s old function “Parameter Dependency”).

Save Parameter Settings

  • 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.

Template Libraries Interactive Control