Exciting Update: Version 1.0.6 is now available, introducing Direct Pine Script Mode, Pine Logs Runtime Bridge, Zero-Repaint Linting, Source Maps, Intrabar MFE/MAE Stats, and expanded Pine v5/v6 Transpiler Parity. Read more
Version: 1.0.6

Multi-Timeframe (MTF)

Multi-Timeframe Analysis (request.security)

The request.security() function lets you evaluate higher-timeframe indicators and synthetic chart styles (such as Heikin Ashi) aligned cleanly onto your active chart bars.

BacktestX Script
request.security(symbol, timeframe, expression, lookahead)
  • symbol: Active chart ticker (syminfo.tickerid / sym) or a modifier ticker such as ticker.heikinashi(syminfo.tickerid) or ticker.standard(syminfo.tickerid).
  • timeframe: Higher-timeframe string such as "5", "15", "60", "1H", "4H", "1D", "1W", or timeframe.period.
  • expression: Pine expression / tuple (e.g., ta.sma(close, 20)) or a JavaScript callback returning the series value.

Example: 1-Hour SMA on a Lower-Timeframe Chart

Pine Script / BacktestX
// Evaluates SMA 20 on 1-hour candles and aligns it to your active chart
htfSma = request.security(syminfo.tickerid, "60", ta.sma(close, 20))
plot(htfSma, title="1H SMA", color=#ffeb3b, linewidth=2)

request.timeframe_data() & timeframe.* Helpers (v1.0.6)

Alongside request.security(), v1.0.6 exposes request.timeframe_data(symbol, tf, indName, ...args) and full timeframe.* chart metadata for timeframe-adaptive scripts:

  • request.timeframe_data(symbol, tf, indName, ...args): Requests a resampled indicator series by name and parameters for a target timeframe.
  • Timeframe Inspection: timeframe.period, timeframe.multiplier, timeframe.in_seconds(), timeframe.isintraday, timeframe.isdaily, timeframe.isweekly, timeframe.ismonthly.
  • Boundary Transitions: timeframe.change(tf) returns true on the first bar where a new period of tf (e.g., "D" or "W") opens—ideal for VWAP resets and session pivots.

Synthetic Chart Modifiers (ticker.*)

Both Direct Pine Mode and JS API mode support synthetic ticker constructors inside multi-timeframe or transform calls (see Chart Transforms & Fundamentals):

  • ticker.heikinashi(sym) & ctx.ticker.heikinashi(bars): Smoothed Heikin Ashi OHLC candles.
  • ticker.standard(sym) & ticker.new(prefix, ticker, session, adjustment): Standard ticker ID builder and normalization.
  • ticker.renko(...), ticker.kagi(...), ticker.pointfigure(...): Brick / reversal chart identifiers.

Zero-Repaint Protection in MTF Scripts

Mixing higher-timeframe requests with barmerge.lookahead_on in historical backtests can leak future bar closes. BacktestX v1.0.6 prevents silent leakage in two ways:

  • //@strict-no-repaint Linter Directive: Emits compile-time gutter warnings with exact source lines whenever barmerge.lookahead_on, negative series offsets, or future bar indices are detected. See Zero-Repaint & Source Maps.
  • Default Safe Lookahead: Higher-timeframe alignment defaults to confirmed bar state (lookahead_off semantics) unless explicitly overridden.