input.timeframe() - Pine Script Function
input.timeframe()
Section titled “input.timeframe()”Overview
Section titled “Overview”Adds an input to the Inputs tab of your script’s Settings, which allows you to provide configuration options to script users. This function adds a dropdown that allows the user to select a specific timeframe via the timeframe selector and returns it as a string. The selector includes the custom timeframes a user may have added using the chart’s Timeframe dropdown.
Syntax
Section titled “Syntax”input.timeframe(defval, title, options, tooltip, inline, group, confirm, display, active) → input stringParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| defval | const string | Determines the default value of the input variable proposed in the script’s “Settings/Inputs” tab |
| from | — | where the user can change it. When a list of values is used with the options parameter |
| the | — | value must be one of them. |
Returns
Section titled “Returns”Value of input variable.
Remarks
Section titled “Remarks”- Result of input.timeframe function always should be assigned to a variable, see examples above.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("input.timeframe", overlay=true)i_res = input.timeframe('D', "Resolution", options=['D', 'W', 'M'])s = request.security("AAPL", i_res, close)plot(s)