TOptValue_TimeOnly
What Is It?
TOptValue_TimeOnly is a class used to define time-only parameters for custom indicators.
These parameters appear in the indicator settings panel and allow the user to input or adjust time values without date information, such as daily trading session times, specific hours of the day, or recurring time-based events.
You must use the createTOptValue_TimeOnly() method of the api object inside Init() method to create an instance.
The UI for this parameter type uses the TimeValue enum, which provides predefined time values in 15-minute intervals from 00:00 to 23:59.
When to Use
Use TOptValue_TimeOnly when you need a configurable parameter for time selection, such as:
Trading session start/end times
Market open/close times
Recurring time-based events
Any time input from the user (without date)
Syntax
// Declare the parameter in the class fields
public MyTimeParameter!: TOptValue_TimeOnly;
public Init(): void {
// Create the parameter
this.MyTimeParameter = this.api.createTOptValue_TimeOnly(defaultTimeValue);
// Register the parameter
this.api.RegOption("MyTimeParameter", TOptionType.TIME_ONLY, this.MyTimeParameter);
}Example
export default class SessionIndicator extends IndicatorImplementation {
public SessionStart!: TOptValue_TimeOnly
public SessionEnd!: TOptValue_TimeOnly
public Init(): void {
// Create the parameters
this.SessionStart = this.api.createTOptValue_TimeOnly(TimeValue['09:00'])
this.SessionEnd = this.api.createTOptValue_TimeOnly(TimeValue['17:00'])
// Register the parameters
this.api.RegOption('SessionStart', TOptionType.TIME_ONLY, this.SessionStart)
this.api.RegOption('SessionEnd', TOptionType.TIME_ONLY, this.SessionEnd)
}
}In this example:
SessionStartdefines when the trading session begins.SessionEnddefines when the trading session ends.
Notes
After creating a parameter, don't forget to register it using
this.RegOptionin theInitmethod.Use
TOptionType.TIME_ONLYwhen registering this parameter type.Default values should use the
TimeValueenum.You can access the value using
this.MyTimeParameter.value.The UI presents users with a dropdown of time values in 15-minute intervals.
This is useful for recurring daily events or session-based filtering.
Last updated