TOptValue_number is a class used to define numeric parameters for custom indicators.
These parameters appear in the indicator settings panel and allow the user to input or adjust numbers such as periods, shifts, price types, and more.
You must use the createTOptValue_number() method of the api object inside Init() method to create an instance.
When to Use
Use TOptValue_number when you need a configurable parameter of type number, such as:
Period length for moving averages
Shift values
Enum values (e.g., MA type, price type)
Any numeric input from the user
Syntax
// Declare the parameter in the class fieldspublicMyParameter!: TOptValue_number;publicInit(): void{ // Create the parameterthis.MyParameter=this.api.createTOptValue_number(defaultValue); // Register the parameterthis.api.RegOption("MyParameter",TOptionType.INTEGER,this.MyParameter);}
Example
In this example:
Period controls how many bars are used in the moving average calculation.
Shift can offset the indicator horizontally.
MAtype selects the type of moving average (e.g., SMA, EMA).
ApplyToPrice defines which price (close, open, high, low) the MA should use.
VShift applies a vertical offset to the line.
Notes
After creating a parameter, don’t forget to register it using this.RegOption in the Init method.
You can access the value using this.MyParameter.value.