timeframe.from_seconds() - Pine Script Function
timeframe.from_seconds()
Section titled “timeframe.from_seconds()”Overview
Section titled “Overview”Converts a number of seconds into a valid timeframe string.
Syntax
Section titled “Syntax”timeframe.from_seconds(seconds) → simple stringParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| seconds | simple int | The number of seconds in the timeframe. |
Returns
Section titled “Returns”A timeframe string compliant with timeframe string specifications.
Remarks
Section titled “Remarks”- 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”.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("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)