Skip to content
Algo Trade Analytics Docs

timeframe.in_seconds() - Pine Script Function

Converts a timeframe string into seconds.

timeframe.in_seconds(timeframe) → simple int
NameTypeDescription
timeframesimple stringTimeframe string in timeframe string specifications format. Optional. The default is timeframe.period.

The “int” representation of the number of seconds in the timeframe string.

  • When the timeframe is “1M” or more, calculations use 2628003 as the number of seconds in one month, which represents 30.4167 (365/12) days.
//@version=6
indicator("`timeframe_in_seconds()`"),// Get a user-selected timeframe.tfInput = input.timeframe("1D")// Convert it into an "int" number of seconds.secondsInTf = timeframe.in_seconds(tfInput)
plot(secondsInTf)