RegOption
Registers a new option parameter for an indicator or strategy.
Syntax
RegOption(name: string, type: TOptionType, optPtrOrValue?: string | number | boolean | TOptValue, inv = true, useInNameWithParams = true): void
Parameters
name
- A string containing the name of the option.type
- The type of the option (from TOptionType enum).optPtrOrValue
- (Optional) The default value for the option.inv
- (Optional) Visibility flag, defaults to true.useInNameWithParams
- (Optional) Whether to include this option in the name with parameters, defaults to true.
Return Value
This method does not return a value.
Description
The RegOption
method registers a new option parameter for an indicator or strategy. This is used to define the configurable parameters that users can adjust when applying the indicator or strategy.
See TOptionType for a complete list of option types.
Example
// Declare parameters as class fields
public Period!: TOptValue_number;
public Color!: TOptValue_number;
public Deviation!: TOptValue_number;
public ShowLabels!: TOptValue_bool;
public FillPriceType!: TOptValue_number;
Init(): void {
// Create parameters
this.Period = this.api.createTOptValue_number(8);
this.Color = this.api.createTOptValue_number(0);
this.Deviation = this.api.createTOptValue_number(0);
this.ShowLabels = this.api.createTOptValue_bool(true);
this.FillPriceType = this.api.createTOptValue_number(0);
// Register a period option
this.api.RegOption("Period", TOptionType.INTEGER, this.Period);
// Register a color option
this.api.RegOption("Deviation", TOptionType.DOUBLE, this.Deviation);
// Register a boolean option
this.api.RegOption("Show Labels", TOptionType.BOOLEAN, this.ShowLabels);
// Register an enum option
this.api.RegOption('Fill Price Type',TOptionType.ENUM_TYPE,this.FillPriceType)
this.api.AddOptionValue('Fill Price Type','Close')
this.api.AddOptionValue('Fill Price Type','HighLow')
}
Last updated