Script parameters
Script parameters
When writing scripts on the TSLab API, you can define parameters that can be configured from the TSLab Optimization tab. Also, these parameters are used to optimize the script.
For example, a script builds an SMA indicator. To calculate it, you need the value of the period by which the indicator is calculated. In order not to write this value in the code, we can add a parameter to the script and use it as a calculation.
This line describes a property of type OptimProperty. The property contains a double type. By default, the value will be 100; during optimization, values from 10 to 200 will be moved over in increments of 1.
There are different types of parameters:
Types of Parameters
OptimProperty
Floating point number (double)
IntOptimProperty
Integer (int)
BoolOptimProperty
Boolean value (bool)
DateTimeOptimProperty
date and time (DateTime)
EnumOptimProperty
Listing (Enum)
StringOptimProperty
String (String)
TimeSpanOptimProperty
Time interval (TimeSpan)
We will write a script that calculates two SMA values, fast and slow. We will pass SMA periods through script parameters:
On the Optimization tab, we see our parameters, where they can be edited.
Last updated