TOptValue_bool
What Is It?
TOptValue_bool is a class used to define boolean (true/false) parameters in custom indicators.
It allows users to enable or disable certain features through the indicator settings panel.
Use the createTOptValue_bool() method from the api object inside Init() method to create an instance.
When to Use
Use TOptValue_bool when you want to let the user:
Toggle a feature on or off
Show or hide additional elements
Enable conditional behavior in your indicator
Syntax
public MyFlag!: TOptValue_bool;
public Init(): void {
// Create the parameter
this.MyFlag = this.api.createTOptValue_bool(defaultValue);
// Register the parameter
this.api.RegOption("MyFlag", TOptionType.BOOLEAN, this.MyFlag);
}Example
In this example:
IsEnabledallows the user to toggle indicator logic on or off.Inside
Calculate(), the logic runs only if the toggle istrue.
Notes
Don't forget to register string parameters using
this.RegOptioninside theInitmethod.Access the value with
this.MyFlag.value.
Last updated