🆕Multi-Timeframe (mtf) (BETA)

triangle-exclamation

Warning

The MTF (Multi-Timeframe) API allows you to work with price data from a different timeframe than the chart you are currently on. This is extremely useful when you want to combine higher-timeframe context (like daily highs, 4H trends, or weekly indicators) with lower-timeframe entries.

MTF handles everything automatically for you. Once you request a timeframe, all mtf.* functions will transparently use that timeframe while normal price functions (high(), closeC(), etc.) will continue using the chart timeframe.

Syntax

mtf.timeframe(timeframe)

Parameters

timeframe string — Defines the timeframe you want to request. Examples: "1D", "240", "60", "15", "5"

Return Value

void This method does not return a value. It prepares the requested timeframe so it can be used later inside onTick.


MTF Functions

Once a timeframe is requested, you can access data from that timeframe using the following functions.

chevron-rightmtf.highhashtag

Returns the high price from the requested timeframe.

Syntax

mtf.high(index, smooth)

Parameters index number Candle index (0 = current MTF candle, 1 = previous, etc.)

smooth boolean

  • true → smooth (interpolated, default)

  • false → stepped (updates only when the MTF candle closes)

Return Value number

chevron-rightmtf.lowhashtag

Returns the low price from the requested timeframe.

Syntax

mtf.low(index, smooth)

Parameters index number Candle index (0 = current MTF candle, 1 = previous, etc.)

smooth boolean

  • true → smooth (interpolated, default)

  • false → stepped (updates only when the MTF candle closes)

Return Value number

chevron-rightmtf.openChashtag

Returns the open price from the requested timeframe.

Syntax

mtf.openC(index, smooth)

Parameters index number Candle index (0 = current MTF candle, 1 = previous, etc.)

smooth boolean

  • true → smooth (interpolated, default)

  • false → stepped (updates only when the MTF candle closes)

Return Value number

chevron-rightmtf.closeChashtag

Returns the close price from the requested timeframe.

Syntax

mtf.closeC(index, smooth)

Parameters index number Candle index (0 = current MTF candle, 1 = previous, etc.)

smooth boolean

  • true → smooth (interpolated, default)

  • false → stepped (updates only when the MTF candle closes)

Return Value number

chevron-rightmtf.volumehashtag

Returns the volume from the requested timeframe.

Syntax

mtf.volume(index, smooth)

Parameters index number Candle index (0 = current MTF candle, 1 = previous, etc.)

smooth boolean

  • true → smooth (interpolated, default)

  • false → stepped (updates only when the MTF candle closes)

Return Value number

chevron-rightmtf.timehashtag

Returns the timestamp from the requested timeframe.

Syntax

mtf.time(index, smooth)

Parameters index number Candle index (0 = current MTF candle, 1 = previous, etc.)

smooth boolean

  • true → smooth (interpolated, default)

  • false → stepped (updates only when the MTF candle closes)

Return Value number

chevron-rightmtf.emahashtag

Calculates an EMA on the requested timeframe and adapts it to the current chart.

Syntax

mtf.ema(src, length, smooth)

Parameters src stringopenhighlowclosehl2hlc3ohlc4

length number EMA period length

smooth boolean Controls interpolation mode

Return Value number

chevron-rightmtf.smahashtag

Calculates an SMA on the requested timeframe.

Syntax

mtf.sma(src, length, smooth)

Parameters src stringopenhighlowclosehl2hlc3ohlc4

length number SMA period length

smooth boolean Controls interpolation mode

Return Value number

chevron-rightmtf.rsihashtag

Calculates an RSI on the requested timeframe.

Syntax

mtf.rsi(src, length, smooth)

Parameters src stringopenhighlowclosehl2hlc3ohlc4

length number RSI period length

smooth boolean Controls interpolation mode

Return Value number

chevron-rightmtf.atrhashtag

Calculates ATR from the requested timeframe.

Syntax

mtf.atr(length, smooth)

Return Value number

Example

Result

circle-info

Tips

Use higher timeframes (like 1D or 4H) to define trend direction and lower timeframes for entries.

Set smooth = false when you want values to update only after the higher timeframe candle closes.

Call mtf.timeframe() only once inside init().

triangle-exclamation

Warning

circle-check

Good Practice

Last updated