# 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

```ts
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

```ts
export default class CustomIndicator extends IndicatorImplementation {
  public IsEnabled!: TOptValue_bool;

  public Init(): void {
    this.IsEnabled = this.api.createTOptValue_bool(true);

    this.api.RegOption("IsEnabled", TOptionType.BOOLEAN, this.IsEnabled);
  }

  public Calculate(index: number): void {
    if (!this.IsEnabled.value) {
      return;
    }

    // Perform calculations only if enabled
  }
}
```

In this example:

* `IsEnabled` allows the user to toggle indicator logic on or off.
* Inside `Calculate()`, the logic runs only if the toggle is `true`.

***

### Notes

* Don't forget to register string parameters using [`this.RegOption`](/fto-indicators-docs/external_parameters_definition/reg-option.md) inside the [`Init` ](/fto-indicators-docs/indicators/indicator-structure/init.md)method.
* You can use the value directly in [`Calculate`](/fto-indicators-docs/indicators/indicator-structure/calculate.md), [`OnShow`](/fto-indicators-docs/indicators/indicator-structure/on-show.md), or other methods as needed.
* Access the value with `this.MyFlag.value`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fto-2.gitbook.io/fto-indicators-docs/indicators/indicator-structure/toptvalue/toptvalue-bool.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
