MMTMMT Docs

Context

Chart metadata and per-bar execution flags available through the global context object.

The global context object exposes market metadata and execution state.

If you need the normalized string form or timeframe classification helpers, use the timeframe.*. context.timeframe remains the raw chart timeframe in seconds.

Market Fields

FieldTypeDescription
context.timeframenumberPrimary/chart timeframe in seconds
context.exchangestringActive exchange
context.symbolstringActive symbol
context.tickSizenumberMinimum price increment
context.stepSizenumberMinimum quantity increment

Per-Bar Flags

FieldTypeDescription
context.isFirstbooltrue when current absolute bar index is 0
context.isHistorybooltrue during history-run execution path
context.isLastbooltrue on the last currently available primary-series bar
context.isNewbooltrue when current unix changed vs previous evaluation
context.isRealtimebooltrue when not in history execution path

Example Value

{
  timeframe: 60,
  exchange: "binancef",
  symbol: "btc/usdt",
  tickSize: 0.1,
  stepSize: 0.001,
  isFirst: false,
  isHistory: false,
  isLast: true,
  isNew: true,
  isRealtime: true
}

Example

//@version=2
indicator("Context Example", true)
const candles = subscribe(data.OHLCV)

function onBar(index) {
    if (context.isHistory) return

    const rounded = math.roundToTick(candles.close(), context.tickSize)
    if (context.isNew) {
        plot("Realtime Close", rounded, { color: color.blue })
    }
}

On this page