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.
| Signature | Returns |
|---|---|
| mtf.open(minutes: int) -> float | Open of the developing higher timeframe candle |
| mtf.high(minutes: int) -> float | Its high so far |
| mtf.low(minutes: int) -> float | Its low so far |
| mtf.close(minutes: int) -> float | Its close so far, which is this bar's close |
| mtf.volume(minutes: int) -> float | Its volume so far |
| mtf.prev_open(minutes: int) -> float | Open of the last finished candle of that timeframe |
| mtf.prev_high(minutes: int) -> float | Its high |
| mtf.prev_low(minutes: int) -> float | Its low |
| mtf.prev_close(minutes: int) -> float | Its close |
| mtf.prev_volume(minutes: int) -> float | Its 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)