Skip to content
TradequixDocsOpen the terminal
OverviewStart here, search, progress
  • Introduction
  • Quickstart
  • How a script runs
  • Types and qualifiers
  • Operators, conditionals and loops
  • Functions and methods
  • Objects and enums
  • Arrays, matrices and maps
  • Strings and colours
  • Time and sessions
  • Bar states
  • Plotting
  • Inputs
  • Technical analysis
  • Drawings and tables
  • Multiple timeframes
  • Strategies
  • Alerts in scripts
  • Repainting
  • The Pine editor
  • Indicator settings
  • Coming from TradingView
  • The data
  • Publish and sell
  • Catalogue and community
  • Your dashboard and earnings
  • Errors and debugging
  • Limits
  • Coverage
  • Built-in catalogue
  • Cookbook
  • Write Pine with AI
  • FAQ
  • Glossary
  • Cheat sheet
  • Function reference
  • Will it run here?
  • Error index

Write

Multiple timeframes

Read another timeframe with request.security. Which timeframes the feed serves directly, which are built from others, and what is refused.

View as MarkdownOpen in ClaudeOpen in ChatGPT

request.security evaluates an expression on another timeframe and brings the result back to your chart. The classic use is a higher-timeframe trend filter on a lower-timeframe chart.

pine
1//@version=62indicator("1h trend on any chart", overlay = true)3tf = input.timeframe("60", "Trend timeframe")4htfEma = request.security(syminfo.tickerid, tf, ta.ema(close, 50))5plot(htfEma, "HTF EMA 50", color = color.orange, linewidth = 2)6bgcolor(close > htfEma ? color.new(color.teal, 92) : color.new(color.red, 92))

This example has no Run button: other timeframes are fetched from the live feed, which the docs' generated series cannot provide. Open the terminal to try it.

Timeframes the feed serves#

These fourteen come straight from the feed, with the string Pine uses for each:

TimeframePine stringTimeframePine string
5 seconds"5S"5 minutes"5"
10 seconds"10S"10 minutes"10"
15 seconds"15S"15 minutes"15"
30 seconds"30S"30 minutes"30"
1 minute"1"1 hour"60" (or "1H")
2 minutes"2"4 hours"240" (or "4H")
3 minutes"3"1 day"D" (or "1D")

Other timeframes#

  • Higher timeframes that are not in the list (for example "W", "45" or "120") are built by combining smaller bars, the same way PineTS does for any provider. They work, with one limit: a weekly bar needs many daily bars, and history is finite, so the earliest values can be na. The editor says when this happens.
  • Anything under 5 seconds is refused with a clear error. The feed has nothing smaller.

Lower timeframes#

request.security_lower_tf returns an array of the lower-timeframe values inside each chart bar, for example the 1-minute closes inside a 1-hour bar.

Rules that keep results honest#

  • request.security uses the chart's own symbol through syminfo.tickerid. Asking for a modified ticker (Heikin Ashi, Renko and similar) fails explicitly instead of quietly serving ordinary candles.
  • Data a candle feed does not carry (request.financial, request.earnings, request.dividends, request.economic, request.footprint, and similar) returns na with a warning in the console.
  • Fetches for other timeframes respect the chart's date range and are limited per run, so a script cannot pull unlimited history.

Watch out

On a live higher-timeframe bar, the value changes until that bar closes. If you want only confirmed values, request the previous bar: request.security(syminfo.tickerid, tf, close[1], lookahead = barmerge.lookahead_on) is the standard non-repainting form.

PreviousDrawings and tablesNext Strategies

On this page

  • Timeframes the feed serves
  • Other timeframes
  • Lower timeframes
  • Rules that keep results honest

Use with AI

View as MarkdownOpen in ClaudeOpen in ChatGPT