RegOption

Registers a new option parameter for an indicator or strategy.

Syntax

RegOption(name: string, type: TOptionType, optPtrOrValue?: string | number | boolean | TOptValue, 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.

  • useInNameWithParams - (Optional) Whether to include this option in the name with parameters, defaults to true.

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

// Register a period option
this.api.RegOption("Period", TOptionType.INTEGER, 21);

// Register a color option
this.api.RegOption("Line Color", TOptionType.COLOR, "blue");

// Register a boolean option
this.api.RegOption("Show Labels", TOptionType.BOOLEAN, true);

// Register an enum option
this.api.RegOption("MA Type", TOptionType.ENUM_TYPE, 0);

Last updated