🆕Multi-Timeframe (mtf) (BETA)
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.
mtf.high
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
mtf.low
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
mtf.openC
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
mtf.closeC
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
mtf.volume
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
mtf.time
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
mtf.ema
Calculates an EMA on the requested timeframe and adapts it to the current chart.
Syntax
mtf.ema(src, length, smooth)
Parameters
src
string
• open
• high
• low
• close
• hl2
• hlc3
• ohlc4
length number EMA period length
smooth boolean Controls interpolation mode
Return Value number
mtf.sma
Calculates an SMA on the requested timeframe.
Syntax
mtf.sma(src, length, smooth)
Parameters
src
string
• open
• high
• low
• close
• hl2
• hlc3
• ohlc4
length number SMA period length
smooth boolean Controls interpolation mode
Return Value number
mtf.rsi
Calculates an RSI on the requested timeframe.
Syntax
mtf.rsi(src, length, smooth)
Parameters
src
string
• open
• high
• low
• close
• hl2
• hlc3
• ohlc4
length number RSI period length
smooth boolean Controls interpolation mode
Return Value number
Example
Result

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().
Warning
Do not call mtf.timeframe() inside onTick.
This can cause incorrect data synchronization and unexpected behavior.
Avoid mixing mtf.* values and normal price values without being aware of their different time origins.
Last updated