Builtins: higher timeframe candles

The candle of a longer timeframe that this bar belongs to, built from the bars the chart holds. The developing candle only ever contains this bar and the ones before it in the same bucket.

SignatureReturns
mtf.open(minutes: int) -> floatOpen of the developing higher timeframe candle
mtf.high(minutes: int) -> floatIts high so far
mtf.low(minutes: int) -> floatIts low so far
mtf.close(minutes: int) -> floatIts close so far, which is this bar's close
mtf.volume(minutes: int) -> floatIts volume so far
mtf.prev_open(minutes: int) -> floatOpen of the last finished candle of that timeframe
mtf.prev_high(minutes: int) -> floatIts high
mtf.prev_low(minutes: int) -> floatIts low
mtf.prev_close(minutes: int) -> floatIts close
mtf.prev_volume(minutes: int) -> floatIts volume
  • minutes is a whole number from 1 to 1440. Candles are counted from midnight UTC, so 60 is the clock hour and 1440 the UTC calendar day. For the futures session use session.open and the session builtins.
  • The first candle of the loaded window answers nan unless the window starts exactly on its boundary, because bars before the window are not there to complete it.
  • A script may read at most 8 different timeframes. Call them at the top level, never inside a loop.
  • Use the chart's own instrument only; there is no other symbol.
let hour_high: float = mtf.prev_high(60)
let hour_low: float = mtf.prev_low(60)
plot.line(hour_high, "#22C55E", 1, "dashed")
plot.line(hour_low, "#EF4444", 1, "dashed")
plot.candle_color(close > mtf.open(240), "#22C55E", 0.3)

Every layer of the market, Orderflow to optionflow, on one chart.

Institutional grade Orderflow data with backtesting and journaling built in. Join the waitlist for early access.

Get Access