# TOptValue\_number

### What Is It?

`TOptValue_number` is a class used to define **numeric parameters** in strategies.\
These parameters appear in the strategy settings panel and allow the user to input or adjust **numbers** such as periods, lot sizes, stop loss levels, 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:

* Trading lot size
* Stop loss and take profit levels
* Period length for indicators
* Price levels for orders
* 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 SimpleBreakoutStrategy extends StrategyImplementation {
  public LotSize!: TOptValue_number;
  public StopLoss!: TOptValue_number;
  public TakeProfit!: TOptValue_number;
  public BreakoutPeriod!: TOptValue_number;
  public PriceType!: TOptValue_number;

  public Init(): void {
    // Create parameters
    this.LotSize = this.api.createTOptValue_number(1.0);
    this.StopLoss = this.api.createTOptValue_number(50);
    this.TakeProfit = this.api.createTOptValue_number(100);
    this.BreakoutPeriod = this.api.createTOptValue_number(20);
    this.PriceType = this.api.createTOptValue_number(TPriceType.CLOSE);

    // Register parameters
    this.api.RegOption("Lot Size", TOptionType.DOUBLE, this.LotSize);
    this.api.RegOption("Stop Loss (pips)", TOptionType.INTEGER, this.StopLoss);
    this.api.RegOption(
      "Take Profit (pips)",
      TOptionType.INTEGER,
      this.TakeProfit
    );
    this.api.RegOption(
      "Breakout Period",
      TOptionType.INTEGER,
      this.BreakoutPeriod
    );
    this.api.RegOption("Price Type", TOptionType.INTEGER, this.PriceType);
  }
}
```

In this example:

* `LotSize` controls the trading volume
* `StopLoss` sets the stop loss distance in pips
* `TakeProfit` sets the take profit distance in pips
* `BreakoutPeriod` defines the period for breakout calculation
* `PriceType` selects which price type to use (see [TPriceType](https://fto-2.gitbook.io/fto-strategies-docs/strategies/constants/price-type))

***

### Notes

* After creating a parameter, don't forget to register it using [`RegOption`](https://fto-2.gitbook.io/fto-strategies-docs/strategies/options/reg-option) in the `Init` method.
* You can access the value using `this.MyParameter.value`.
