Adds a timeframe setting to the script and returns it as a string such as "D" or "60".
input.timeframe returns the timeframe text the user entered, or defval until it is changed. Timeframe strings use the Pine forms: a number of minutes such as "15" or "240", and "D", "W" or "M" for days, weeks and months, optionally with a multiplier such as "2D".
Hand the result to request.security as its timeframe to read data from another timeframe. An empty string means the chart's own timeframe.
Syntax
input.timeframe(defval: const string, title: const string (optional), options: tuple of const string values: [val1, val2, ...] (optional), tooltip: const string (optional), inline: const string (optional), group: const string (optional), confirm: const bool (optional), display: const plot_display (optional), active: input bool (optional)) -> input stringArguments
| Name | Type | Default | Description |
|---|---|---|---|
| defval | const string | required | Default timeframe string. An empty string stands for the chart's timeframe. |
| title | const string | na | Name shown in the Settings dialog, the legend and the Data Window. |
| options | tuple of const string values: [val1, val2, ...] | na | A list of allowed timeframes, written ["60", "D", "W"]. When given, the setting is a dropdown. |
| tooltip | const string | na | Text shown in a tooltip beside the input in the Settings dialog. |
| inline | const string | na | Entries sharing the same inline text sit on one row of the Settings dialog. |
| group | const string | na | Heading the input is listed under in the Settings dialog. |
| confirm | const bool | false | When true, the script asks for this value when it is first added to the chart. |
| display | const plot_display | display. | Where the value appears: a display.* constant or a combination of them. |
| active | input bool | true | When false, the input is greyed out and cannot be edited. |
Returns
input string: the timeframe string.
Remarks
- On Sidechair: the setting is a text field unless options is given, and the text is not checked until
request.securityuses it. - On Sidechair: confirm, display and active are accepted and ignored.
Example
//@version=6
indicator("HTF close", overlay = true)
tf = input.timeframe("D", "Timeframe")
htfClose = request.security(syminfo.tickerid, tf, close)
plot(htfClose, "HTF close", color = color.purple, style = plot.style_stepline)See also
Runs on Sidechair