Sidechair

input.timeframe()

Browse the reference

Adds a timeframe setting to the script and returns it as a string such as "D" or "60".

Try it in the editor

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

Pine Script
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 string

Arguments

NameTypeDefaultDescription
defvalconst stringrequiredDefault timeframe string. An empty string stands for the chart's timeframe.
titleconst stringnaName shown in the Settings dialog, the legend and the Data Window.
optionstuple of const string values: [val1, val2, ...]naA list of allowed timeframes, written ["60", "D", "W"]. When given, the setting is a dropdown.
tooltipconst stringnaText shown in a tooltip beside the input in the Settings dialog.
inlineconst stringnaEntries sharing the same inline text sit on one row of the Settings dialog.
groupconst stringnaHeading the input is listed under in the Settings dialog.
confirmconst boolfalseWhen true, the script asks for this value when it is first added to the chart.
displayconst plot_displaydisplay.allWhere the value appears: a display.* constant or a combination of them.
activeinput booltrueWhen 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.security uses it.
  • On Sidechair: confirm, display and active are accepted and ignored.

Example

Pine ScriptHigher-timeframe closeOpen in editor
//@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