Draw the prior day's high, low and close
This indicator draws three horizontal levels over an intraday chart: the high, the low and the close of the session before the one you are looking at. Each session's three levels are flat segments that start on the session's second bar.
You need a running Taji and a way to add an indicator to a chart: ask your connected agent to write and bind this source, or make the write and bind calls yourself as Your first indicator does. Set the chart to an intraday interval first: on a daily chart every bar is a session of its own.
Taji ships a Prior Day Levels indicator that reads the vendor's daily bar. This one builds the levels from the bars on your chart, to show how an anchor input and an indicator's state work together.
import { indicator, input, plot } from "@taji/indicators";
export default indicator({
name: "Prior session levels",
pane: "price",
inputs: { day: input.anchor("session") },
plots: {
prior_high: plot.step_breaks({ title: "Prior high", color: "#26a69a" }),
prior_low: plot.step_breaks({ title: "Prior low", color: "#ef5350" }),
prior_close: plot.step_breaks({ title: "Prior close", color: "#ff9800" }),
},
setup: () => ({ high: NaN, low: NaN, close: NaN, prior_high: NaN, prior_low: NaN, prior_close: NaN }),
next(bar, s, { inputs }) {
const starts = inputs.day.starts;
if (starts) {
s.prior_high = s.high;
s.prior_low = s.low;
s.prior_close = s.close;
s.high = bar.high;
s.low = bar.low;
} else {
s.high = Math.max(s.high, bar.high);
s.low = Math.min(s.low, bar.low);
}
s.close = bar.close;
const draw = (level: number) => (starts ? NaN : level);
return { prior_high: draw(s.prior_high), prior_low: draw(s.prior_low), prior_close: draw(s.prior_close) };
},
});

import { indicator, input, plot }takes what it needs from@taji/indicators. There is notahere: the levels are plain numbers.inputs: { day: input.anchor("session") }declares an anchor input. Innextit is{ starts, period_start }:startsis true on the first bar of each session and on the first bar of the chart, andperiod_startis that session's first trading day asyyyymmdd. The kernel computes it from the instrument's calendar, so you never compare timestamps yourself. An anchor exists per bar only: reading it insetupthrows.pane: "price"andplotsdraw threestep_breakslines over the bars, on the price scale. A step line holds each value flat across the bar, andstep_breaksleaves a gap where the value isNaN. That is how the first session, with no session before it, draws nothing, and how each session's levels end up as their own segments.setupreturns the state, six numbers that start asNaN(na): the runninghigh,lowandcloseof the current session, and the threeprior_values the plots show. The kernel commits the state on each close and restores it on each tick of the forming bar, so you mutate it freely.const startsandif (starts)read the anchor once, and theifruns on the first bar of a session. The running values then hold the session that has just ended, so they become theprior_values, and the runninghighandlowstart over from this bar.elsewidens the runninghighandlowwith each later bar of the session.s.close = bar.closekeeps the latest close, so on the next session's first bar it is the last bar's close of this one.drawandreturngive the threeprior_values for every bar except astartsbar, wheredrawreturnsNaN. The values do not change inside a session, so each plot is flat, and the gap on thestartsbar breaks the line there: the old session's levels end, and the new session's begin on the next bar, with no vertical step between them.
The kernel serves the indicator's rows, one per bar. These are ten of them (the example's rows.jq picks them): the last three bars of one session, then the first seven of the next, the first of them its starts bar:
[
{
"start_dt": "2026-12-03T20:15:00+00:00",
"prior_high": 143.99,
"prior_low": 142.7,
"prior_close": 143.51
},
{
"start_dt": "2026-12-03T20:30:00+00:00",
"prior_high": 143.99,
"prior_low": 142.7,
"prior_close": 143.51
},
{
"start_dt": "2026-12-03T20:45:00+00:00",
"prior_high": 143.99,
"prior_low": 142.7,
"prior_close": 143.51
},
{
"start_dt": "2026-12-04T14:30:00+00:00",
"prior_high": null,
"prior_low": null,
"prior_close": null
},
{
"start_dt": "2026-12-04T14:45:00+00:00",
"prior_high": 142.15,
"prior_low": 140.16,
"prior_close": 140.88
},
{
"start_dt": "2026-12-04T15:00:00+00:00",
"prior_high": 142.15,
"prior_low": 140.16,
"prior_close": 140.88
},
{
"start_dt": "2026-12-04T15:15:00+00:00",
"prior_high": 142.15,
"prior_low": 140.16,
"prior_close": 140.88
},
{
"start_dt": "2026-12-04T15:30:00+00:00",
"prior_high": 142.15,
"prior_low": 140.16,
"prior_close": 140.88
},
{
"start_dt": "2026-12-04T15:45:00+00:00",
"prior_high": 142.15,
"prior_low": 140.16,
"prior_close": 140.88
},
{
"start_dt": "2026-12-04T16:00:00+00:00",
"prior_high": 142.15,
"prior_low": 140.16,
"prior_close": 140.88
}
]
Captured 2026-12-04 on a headless kernel reading made-up 15-minute bars for SPY.
- The first three rows are the last bars of 2026-12-03, at 15:15, 15:30 and 15:45 New York time (20:15 to 20:45 UTC). They carry the levels of the session before it: high 143.99, low 142.70, close 143.51.
- The fourth row, 14:30 UTC on 2026-12-04, is the session's first bar, 09:30 in New York, and
startsis true on it. All three levels arenullthere: that is the break between the two sessions' lines. - The next row onward carries 142.15, 140.16 and 140.88: the high, low and close of 2026-12-03, the session the first three rows closed. They were captured while 2026-12-04 was still trading, so its own high, low and close are not drawn yet: they become levels at the next
startsbar. - The first session the chart holds has no session before it, so nothing is drawn there, and the levels it produces cover only the bars the chart holds.
Change it
Draw the prior week's levels instead: change the anchor's period to "week", which starts on a week's first trading bar even when its Monday is a holiday.
- inputs: { day: input.anchor("session") },
+ inputs: { day: input.anchor("week") },
Add the midpoint between the prior high and low as a fourth line:
prior_close: plot.step_breaks({ title: "Prior close", color: "#ff9800" }),
+ prior_mid: plot.step_breaks({ title: "Prior mid", color: "#9e9e9e" }),
},
- return { prior_high: s.prior_high, prior_low: s.prior_low, prior_close: s.prior_close };
+ return {
+ prior_high: s.prior_high,
+ prior_low: s.prior_low,
+ prior_close: s.prior_close,
+ prior_mid: (s.prior_high + s.prior_low) / 2,
+ };
Next
- Inputs: sources, anchors and declared data, and when each is readable.
- Outputs: every plot kind, colour, fill and drawing an indicator can return.
- Indicator reference: every field, kind, default, limit and refusal.