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

// 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

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)


Notes

  • After creating a parameter, don't forget to register it using RegOption in the Init method.

  • You can access the value using this.MyParameter.value.

Last updated