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.
request.security(symbol, timeframe, expression, lookahead)symbol: Active chart ticker (syminfo.tickerid/sym) or a modifier ticker such asticker.heikinashi(syminfo.tickerid)orticker.standard(syminfo.tickerid).timeframe: Higher-timeframe string such as"5","15","60","1H","4H","1D","1W", ortimeframe.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
// 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)returnstrueon the first bar where a new period oftf(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-repaintLinter Directive: Emits compile-time gutter warnings with exact source lines wheneverbarmerge.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_offsemantics) unless explicitly overridden.