TOptValue_str
What Is It?
TOptValue_str
is a class used to define string parameters in custom indicators.
It allows users to enter or modify text values in the indicator settings panel.
Use the createTOptValue_str()
method from the api
object inside Init()
method to create an instance.
When to Use
Use TOptValue_str
when you want to let the user:
Input custom labels or names
Define identifiers or tags
Set any free-form text value
Syntax
// Declare the parameter in the class fields
public MyText!: TOptValue_str;
public Init(): void {
// Create the parameter
this.MyText = this.api.createTOptValue_str("default text");
// Register the parameter
this.api.RegOption("MyText", TOptionType.STRING, this.MyText);
}
Example
export default class CustomIndicator extends IndicatorImplementation {
public Name!: TOptValue_str;
public Init(): void {
this.Name = this.api.createTOptValue_str("Custom Indicator");
this.api.RegOption("Name", TOptionType.STRING, this.Name);
}
}
In this example:
Name
is a string parameter that can be changed by the user.The value can be accessed via
this.Name.value
.
Notes
Don't forget to register string parameters using
this.RegOption
inside theInit
method.You can use the value directly in
Calculate
,OnShow
, or other methods as needed.
Last updated