TOptValue_DateOnly
What Is It?
TOptValue_DateOnly is a class used to define date-only parameters for custom indicators.
These parameters appear in the indicator settings panel and allow the user to input or adjust date values without time information, such as specific trading days, start dates, or end dates.
You must use the createTOptValue_DateOnly() method of the api object inside Init() method to create an instance.
When to Use
Use TOptValue_DateOnly when you need a configurable parameter of date only, such as:
Start date for calculations (without specific time)
End date for a period (without specific time)
Specific trading day to highlight or filter
Date-based filters that don't require time precision
Syntax
// Declare the parameter in the class fields
public MyDateParameter!: TOptValue_DateOnly;
public Init(): void {
// Create the parameter
this.MyDateParameter = this.api.createTOptValue_DateOnly(defaultValue);
// Register the parameter
this.api.RegOption("MyDateParameter", TOptionType.DATE_ONLY, this.MyDateParameter);
}Example
export default class DateRangeIndicator extends IndicatorImplementation {
public StartDate!: TOptValue_DateOnly
public EndDate!: TOptValue_DateOnly
public Init(): void {
// Create the parameters
const startDate = this.api.createFTODate('2024-01-01')
const endDate = this.api.createFTODate('2024-12-31'')
this.StartDate = this.api.createTOptValue_DateOnly(startDate)
this.EndDate = this.api.createTOptValue_DateOnly(endDate)
// Register the parameters
this.api.RegOption('StartDate', TOptionType.DATE_ONLY, this.StartDate)
this.api.RegOption('EndDate', TOptionType.DATE_ONLY, this.EndDate)
}
}In this example:
StartDatedefines the beginning of the analysis period.EndDatedefines the end of the analysis period.
Notes
After creating a parameter, don't forget to register it using
this.RegOptionin theInitmethod.You can access the value using
this.MyDateParameter.value.Use
TOptionType.DATE_ONLYwhen registering this parameter type.This is useful when you only care about the date and not the specific time of day.
Last updated