Parameters

What Are Parameters?

Indicator parameters are configurable settings that allow users to customize how an indicator behaves and looks. They appear in the indicator’s settings panel and can be modified without changing the code.


How It Works

To make a parameter configurable, it must be created using one of the TOptValue types , created and registered inside the Init() method.

Any variable that does not extend TOptValue is considered internal and will not be visible or editable in the user interface.


Common Parameter Types

Here are some of the commonly used TOptValue types:

  • TOptValue_number — numeric values (e.g., period, shift)

  • TOptValue_bool — true/false switches

  • TOptValue_string — string input


Example

export default class CustomIndicator extends IndicatorImplementation {
  // Configurable parameters
  public Period!: TOptValue_number;
  public ShowLabels!: TOptValue_bool;
  public ApplyToPrice!: TOptValue_number;

  // Internal parameter (not configurable)
  public internalParameter: number = 0;

  public Init(): void {
    // Create parameters
    this.Period = this.api.createTOptValue_number(8);
    this.ShowLabels = this.api.createTOptValue_bool(true);
    this.ApplyToPrice = this.api.createTOptValue_number(TPriceType.CLOSE);
    // Register parameters so they show up in the UI
    this.api.RegOption("Period", TOptionType.INTEGER, this.Period);
    this.api.RegOption("ShowLabels", TOptionType.BOOLEAN, this.ShowLabels);
    this.api.RegOption("ApplyToPrice", TOptionType.INTEGER, this.ApplyToPrice);
  }
}

Key Rules

  • Only TOptValue-based parameters are configurable

  • You must register each parameter inside the Init method using this.api.RegOption

  • Parameters control how the indicator works and looks — use them for anything the user might want to tweak

Last updated