Skip to content
Algo Trade Analytics Docs

timeframe.from_seconds() - Pine Script Function

Converts a number of seconds into a valid timeframe string.

timeframe.from_seconds(seconds) → simple string
NameTypeDescription
secondssimple intThe number of seconds in the timeframe.

A timeframe string compliant with timeframe string specifications.

  • If no valid timeframe exists for the quantity of seconds supplied, the next higher valid timeframe will be returned. Accordingly, one second or less will return “1S”, 2-5 seconds will return “5S”, and 604,799 seconds (one second less than 7 days) will return “7D”.
//@version=6
indicator("HTF Close", "", true)
int chartTf = timeframe.in_seconds()string tfTimes5 = timeframe.from_seconds(chartTf * 5)float htfClose = request.security(syminfo.tickerid, tfTimes5, close)
plot(htfClose)