TOptValue_DateTime

What Is It?

TOptValue_DateTime is a class used to define date and time parameters for custom indicators. These parameters appear in the indicator settings panel and allow the user to input or adjust date and time values such as start times, end times, or specific moments in trading history.

You must use the createTOptValue_DateTime() method of the api object inside Init() method to create an instance.


When to Use

Use TOptValue_DateTime when you need a configurable parameter of date and time, such as:

  • Start date and time for calculations

  • End date and time for a period

  • Specific moment to trigger indicator behavior

  • Time-based filters for trading sessions


Syntax

// Declare the parameter in the class fields
public MyDateTimeParameter!: TOptValue_DateTime;

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

// Register the parameter
this.api.RegOption("MyDateTimeParameter", TOptionType.DATE_TIME, this.MyDateTimeParameter);

}

Notes

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

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

  • Use TOptionType.DATE_TIME when registering this parameter type.

Last updated