πŸ†•timeframe

Creates a timeframe (resolution) selector so users can choose which timeframe your logic should run on (for example 5m, 1h, 1D). This is essential for multi-timeframe indicators, higher-timeframe filters, or confirmation logic β€” without forcing users to edit code.

Syntax (one line)

input.timeframe(title, value?, id?, group?, tooltip?, inline?, includeChartOption?)

Parameters

title (string) Β· Label shown in the inputs panel (e.g., "Timeframe"). value (string) Β· Default timeframe value (must be one of the allowed aliases). id (string) Β· Optional unique identifier (defaults to a simplified version of title). group (string) Β· Optional group name to organize inputs in the UI. tooltip (string) Β· Optional helper text shown on hover. inline (string) Β· Optional inline key to place inputs on the same row. includeChartOption (boolean) Β· If true, adds "Chart" as an option (uses the current chart timeframe).

Allowed Timeframe Values

(case-insensitive)

  • "1m", "3m", "5m", "15m", "30m", "45m"

  • "1h", "2h", "3h", "4h"

  • "1D", "1W"

  • "Chart" (only if includeChartOption is true)

⚠️ Any value outside this list will throw an error.

Return Value

(string) Β· The selected timeframe value, which you can use inside onTick.

Example

What this does: Adds a timeframe selector so the user can choose whether calculations run on the current chart timeframe or a higher one (like 1H or 1D).

Result

circle-info

Tips

  • Use input.timeframe when you want to add higher-timeframe confirmation (for example: trend on 1H, entries on 5m).

  • "Chart" is ideal as a default option so the script behaves normally unless the user explicitly changes it.

  • Pair it with input.src so users can fully control what price and what timeframe drive your logic.

  • Keep timeframe inputs grouped (using group) to avoid clutter in indicators with many settings.

triangle-exclamation

Warning

circle-check

Good Practice

Last updated