Timeframe
Returns the current chart timeframe.
Syntax
Timeframe(): numberReturn Value
Returns a number representing the current timeframe in seconds.
Description
The Timeframe method returns the timeframe of the current chart. The timeframe is represented in seconds, with special values for longer periods.
Example
// Get the current timeframe
const timeframe = this.api.Timeframe();
console.log(`Current timeframe: ${timeframe}`);
// Check for specific timeframes
if (this.api.Timeframe() === 60) {
// H1 specific logic
} else if (this.api.Timeframe() === 1440) {
// Daily chart logic
}Last updated