> For the complete documentation index, see [llms.txt](https://fto-2.gitbook.io/fto-indicators-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fto-2.gitbook.io/fto-indicators-docs/indicators/indicator-structure/toptvalue/toptvalue-number.md).

# TOptValue\_number

### What Is It?

`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

```ts
// Declare the parameter in the class fields
public MyParameter!: TOptValue_number;

public Init(): void {
    // Create the parameter
    this.MyParameter = this.api.createTOptValue_number(defaultValue);

    // Register the parameter
    this.api.RegOption("MyParameter", TOptionType.INTEGER, this.MyParameter);
}
```

***

### Example

```ts
export default class MovingAverage extends IndicatorImplementation {
  public Period!: TOptValue_number;
  public Shift!: TOptValue_number;
  public MAtype!: TOptValue_number;
  public ApplyToPrice!: TOptValue_number;
  public VShift!: TOptValue_number;

  public Init(): void {
    // Create the parameter
    this.Period = this.api.createTOptValue_number(8);
    this.Shift = this.api.createTOptValue_number(0);
    this.MAtype = this.api.createTOptValue_number(E_MAType.SMA);
    this.ApplyToPrice = this.api.createTOptValue_number(TPriceType.CLOSE);
    this.VShift = this.api.createTOptValue_number(0);

    // Register the parameter
    this.api.RegOption("Period", TOptionType.INTEGER, this.Period);
    this.api.RegOption("Shift", TOptionType.INTEGER, this.Shift);
    this.api.RegOption("MAtype", TOptionType.INTEGER, this.MAtype);
    this.api.RegOption("ApplyToPrice", TOptionType.INTEGER, this.ApplyToPrice);
    this.api.RegOption("VShift", TOptionType.INTEGER, this.VShift);
  }
}
```

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`](/fto-indicators-docs/external_parameters_definition/reg-option.md) in the [`Init`](/fto-indicators-docs/indicators/indicator-structure/init.md) method.
* You can access the value using `this.MyParameter.value`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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-number.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.
