Writing an indicator
A TypeScript module in the desk that Taji runs for the chart, the same way for every client. Types come from references/taji.d.ts (declare module "@taji/indicators"): point your editor's paths at it and type-check before you write, because Taji only strips types and never checks them.
The loop is call verb/desk/<id>/indicators/write {name, source, test?}, then call verb/desk/<id>/chart/<pane>/add_indicator {definition: "<name>", params: {}} (params is required; {} takes the defaults), then read it back (read get/indicators). Each route's body is describe {route}'s schema, its codes refusals.
The model
setup({inputs})runs once per instance and returns the state. Create everyta.*handle here;tathrows anywhere else.next(bar, s, {inputs, ctx, log})runs for each bar and returns{<plot>: number}. ReturnNaNor leave a plot out for na. A script may have no plots and only draw (§ Drawings and tables).- A tick runs
nextfrom the state committed by the bar before, so a forming bar can run many times and each run starts clean. Only a close commits. bar.timeis UTC seconds of the bar's open (Pine'stimeis milliseconds).- Input,
dataand plot names share one namespace: never give a plot an input's name.calc,calc_closes,offset,originandstyleare reserved input names (the binding's own settings),colorsa reserved plot name. - A name is
[a-z][a-z0-9_]*, at most 64 characters, and no registered indicator's. A write is refused for a TypeScriptenum, anamespace, a constructor parameter property, an import of anything but@taji/indicators, more than 32 inputs or more than 8dataentries. plot.levels([...])draws fixed horizontal lines and is not returned fromnext.series.eq ne gt ge lt lecompare as Pine's operators do (within 1e-10 is equal; NaN is na),series.round,series.tostring(a pattern rounds half up and%multiplies, no format is the shortest form to 10 decimals,"percent"is not multiplied),series.format({n},{n,number,<pattern>}half even,{n,date|time,<pattern>}in UTC),series.nz,series.naandseries.fixnanare Pine'smath.round,str.tostring,str.format,nz,naandfixnan;"mintick","percent"and"volume"are itsformat.*.ctx.syminfois the chart symbol's{tickerid, type, currency, mintick, pointvalue, timezone, session}as Pine'ssyminfo.*names them, frozen, a field Taji does not knownull(an equity'stype, a future'stimezone);"mintick"pads toctx.syminfo.mintickunless the third argument is given.%is JavaScript's, not Pine's: Pine floors the quotient (-1 % 100is 99), JavaScript's follows the dividend (-1), so a port writesa - b * Math.floor(a / b).
Plots and colour
plot.<kind>({title?, color?, width?}), kind one of Pine's plot styles, or one of its other plot calls:
| kind | draws | Pine |
|---|---|---|
line, line_breaks | a line; line_breaks gaps where a value is na | plot.style_line, style_linebr |
step, step_breaks, step_diamonds | a step line; step_diamonds a diamond at each value | style_stepline, _linebr, _diamond |
area, area_breaks | a line with the area under it filled | style_area, style_areabr |
histogram | thin bars from zero | style_histogram |
columns | wide bars from zero (MACD's histogram) | style_columns |
circles | a dot per value | style_circles |
cross | a cross per value (Parabolic SAR) | style_cross |
char(c, {at}) | the one character c just above or below its value, or on it (at above default, below, value): return the bar's high or low to sit over or under the bar | plotchar |
arrow | an arrow up for a positive value, down for a negative one, its length by magnitude among the served rows; off the price scale | plotarrow |
candle, bar | a candle or an OHLC bar: next returns {open, high, low, close}, served as four columns <plot>.open … <plot>.close | plotcandle, plotbar |
bgcolor | the pane's background over each bar with a number, in its palette's colour; off the price scale | bgcolor |
barcolor | recolours the chart's candles over each bar with a number; off the price scale | barcolor |
title (1 to 64 characters) names the plot's Style row, else its name does. color is #rrggbb or #rrggbbaa, hex in any case; none on a script's plot serves #2962ff (TradingView's rendered default for a new drawing, not Pine's color.blue). width is 1 to 4. plot.marker({shape, at}) draws a shape where next returns a number. A script holds at most 32 columns (a candle or a bar is four).
A plot with colors: [...] (1 to 8 words, instead of color) is painted: next also returns colors: {<plot>: slot}, an index into that palette for this bar, and the kernel serves it per row. A slot that is not an integer inside the palette, or NaN or absent, draws nothing for the bar. A painted line's segment takes the colour of the bar it ends on; a candle's or bar's slot colours all four parts. color.rgb(r, g, b, transp = 0) and color.new(c, transp) build a word as Pine does: transp 0 gives #rrggbb, else #rrggbbaa (transp 100 is clear); a bad channel or colour throws.
A plot or fill with colors: "computed" (instead of color or a palette) takes its colour per bar from next's colors: {<name>: word}, any #rrggbb[aa] or null for none; Style offers it no swatch. color.from_gradient(value, bottom, top, bottom_color, top_color) is Pine's: the alpha and the alpha-premultiplied channels interpolated and floored, the end colours at and beyond [bottom, top]; a null end colour is clear black (a null bottom keeps the top's red, green and blue, its alpha rising from 0), and a NaN value or bound, or a clear result, is null. color.r/g/b(c) read a channel 0 to 255 and color.t(c) the transparency 0 to 100 ((255 − alpha) × 100 / 255 rounded, so color.new(c, 50) reads 50); null reads 0, 0, 0 and 100, as Pine's na colour.
fills: {<name>: fill(a, b, {title?, color? | colors?, alpha?})} in the definition shades between a and b, each a plot's name (not an arrow, candle, bar, bgcolor, barcolor or levels), a level's value, or a constant, with at least one plot or level; alpha 0 to 1 (default 1). Up to 16, their names in the plots' namespace. A painted fill's slot comes from next's colors: {<fill>: slot} as a plot's does, its rows on the fill's first plot.
MACD's histogram in four colours (above or below zero, then rising or falling):
plots: {
macd: plot.line({ title: "MACD" }),
signal: plot.line({ title: "Signal line" }),
hist: plot.columns({ title: "Histogram", colors: ["#26a69a", "#b2dfdb", "#ffcdd2", "#ff5252"] }),
},
setup: () => ({ /* the ta handles, */ prev: NaN }),
// in next, `hist` this bar's histogram and s.prev the last one:
const slot = hist !== hist ? NaN : (hist >= 0 ? 0 : 2) + (hist > s.prev ? 0 : 1);
s.prev = hist;
return { macd, signal, hist, colors: { hist: slot } };
Drawings and tables
line.new, label.new, box.new, polyline.new, table.new, card and bars are callable in next only. They are state: committed on a close and restored on a tick, so a tick's new, set or cell is undone at the next tick and redone from the last close, and a recompute starts empty and rebuilds. Keep the handles in setup's state, and make every drawing from the bar's own data so a replay and live end alike.
- Every drawing's x is in its
xloc:"bar_index"(the default, Pine's) actx.index, from 10,000 bars before the bar it is written on to 500 after;"bar_time"abar.time, any instant, the future included. Either is served as a time, a bar index off the series on the end bar's spacing, with its bars off the series beside it. A y is a price; NaN draws nothing. line.new({x1, y1, x2, y2, xloc?, extend?, color?, width?, style?}): defaults#2962ff, width 1,solid(dashed,dotted,arrow_left,arrow_right,arrow_both, a head at x1, x2 or both),extendnone(righta ray from x1 through x2,leftfrom x2 through x1,both).label.new({x, y, text?, xloc?, yloc?, color?, style?, textcolor?, size?, textalign?, tooltip?}): TradingView's rendered defaults (label_downin#2962ff, white text,normal);stylePine'slabel.style_*without the prefix;ylocabovebar/belowbarsits it on its bar's high or low. Text at most 40960 UTF-16 units, as Pine'sstr.lengthcounts.box.new({left, top, right, bottom, xloc?, extend?, border_color?, border_width?, border_style?, bg?, text?, text_color?, text_size?, text_halign?, text_valign?}): border andbg#2962ff(null for none),extendas a line's.polyline.new({points: [{x, y}], xloc?, curved?, closed?, line_color?, fill_color?, line_style?, line_width?}): up to 10,000 points joined in order (curvedby a smooth curve through them),closedback to the first,fill_colorinside; it has noset.- Each returns a handle:
set(partial)(not a polyline),get()the record as written (null once deleted or evicted),delete(). The handles whosegetis not null are Pine'sline.alland the like. The definition'smax_lines,max_labels,max_boxesandmax_polylines(1 to 500, polylines 1 to 100, default 50) cap each kind as Pine's: a kind holds up to its cap plus 5, and the next deletes its oldest down to the cap (Taji's measured behaviour, as TradingView's lines and polylines show it; labels and boxes by analogy). table.new(position, columns, rows, {bg?, frame?, frame_width?, border?}): 1 to 20 columns, 1 to 100 rows, one table per position (top_left top_center top_right middle_left middle_center middle_right bottom_left bottom_center bottom_right); a new one at a held position replaces the old. It returns aTable:cell(column, row, {text, color?, bg?, halign?, size?})(from 0;textat most 40960 UTF-16 units, as Pine'sstr.lengthcounts: an emoji is two;frame_widthpx offrameoutside the cells, 0 by default; defaults colour#363a45, nobg,center,normal; sizestiny small normal large huge),clear(),delete().card(position, {values, pill?, caption?, estimate?})orcard(position, null): 1 to 12values{label, value, unit, signed?}(label1 to 64 characters;valuea number, NaN or infinite drawn "—";unitprice usd shares contracts ratio percent count, which the window formats, so pass numbers, neverseries.tostringtext);pill{text 1 to 32, tone}(positive negative neutral);captionat most 128;estimateadds "estimate" to the head. One table or one card per position, the newest wins;nullremoves the card there. Fill it onctx.last.bars({categories, unit, signed?, caption?, estimate?})orbars(null): one signed bar per category{label 1 to 32, sub? at most 32, value}, 1 to 50 in order, a NaNvaluedrawing no bar. It draws in the binding's own pane, which it takes whole: the definition needspane: "own"and no plots, or the call throws. One panel a binding, a call replaces it.ctx.lastis true on history's last bar and on every live bar: fill a table or a card there, not on every bar.
A zig-zag sketch: one leg line, redrawn as the live bar moves.
import { indicator, input, line, type Line } from "@taji/indicators";
export default indicator({
name: "Zig Zag", pane: "price",
inputs: { deviation: input.float(5, { min: 0.01 }) },
setup: () => ({ dir: 0, ext: NaN, ext_time: NaN, leg: null as Line | null }),
next(bar, s, { inputs }) {
const d = inputs.deviation / 100;
if (s.dir === 0) { s.dir = 1; s.ext = bar.high; s.ext_time = bar.time; return; }
const up = s.dir === 1;
const farther = up ? bar.high > s.ext : bar.low < s.ext;
const turned = up ? bar.low <= s.ext * (1 - d) : bar.high >= s.ext * (1 + d);
if (farther) {
s.ext = up ? bar.high : bar.low; s.ext_time = bar.time;
s.leg?.set({ x2: s.ext_time, y2: s.ext });
} else if (turned) {
const y2 = up ? bar.low : bar.high;
s.leg = line.new({ x1: s.ext_time, y1: s.ext, x2: bar.time, y2, xloc: "bar_time" });
s.dir = -s.dir; s.ext = y2; s.ext_time = bar.time;
}
},
});
Reading it back, and the look
GET /get/indicators serves the numeric outputs as row keys in output order, then a <plot>:color column per painted plot and a fill:<k> column per painted fill (that bar's slot or null; a computed one's UInt32 0xRRGGBBAA, 0 for none). fields is each column's own metadata: an output's kind, title, color, colors, width, line, price_line, offset (only when not 0), visible (only when hidden), a char plot's char and at, a marker's shape and at, computed on a computed output, a slot column's of. meta.drawings is the whole current set of drawings and tables ({lines, labels, boxes, polylines, tables}, plus cards and bars while held, each record as written with every x a time, the full shape in describe {route: "get/indicators", prose: true}), absent while a script holds none; Pivot Points serve their levels' lines and labels there. A script with no plots has rows of start_dt alone and no fields.
The binding's params.style changes the look and never recomputes: update_indicator {id, params: {…inputs, style: {plots: {hist: {colors: [...], width: 2}}, show: {values: false}, precision: 2, visibility: {minutes: [5, 59], days: false}}}}. params replace wholesale, so send the whole style each time. Its keys: plots.<output> {visible, color (an unpainted one), colors (a painted one, the palette's length), neither on a computed one, width 1 to 4, kind (line, line_breaks, step, step_breaks, step_diamonds, histogram, cross, area, area_breaks, columns, circles: Pine's plot styles), price_line, line (solid, dashed, dotted)}; fills[k] {visible, colors, alpha 0 to 1} and levels[k] {visible, color, line, value} (value moves the level; the served level also carries its title), null for one left alone; a colour may end in an alpha (#rrggbbaa), which on a fill's colors entry replaces alpha for the bars in that slot; show {values, inputs, scale_labels, lines, boxes, labels, tables}; precision 0 to 8; visibility {minutes, hours, days, weeks, months}, each [lo, hi] or false to hide that unit; the full contract is the style property of the row at desk/<id>/catalog/<name>, and add_indicator's params in its describe. A refusal is invalid_params starting style: .
Rules
- State is plain data (numbers, strings, booleans, arrays, plain objects) or
tahandles. A function, a class instance or aMapis refused. - No
Math.random,Date.nowor argument-lessnew Date(): each throwsnot deterministic. No module-level mutable state, which would differ between a replay and live. ta.rsi,ta.ema,ta.rmaandta.smaare the built-ins' own code, so the same length gives the same numbers.- A
sourceoranchorinput is per bar: readinginputs.<name>insetupthrows. Read it innext. - Nothing refuses an unknown name at run time: a key
nextreturns that no plot names is ignored, and a plot option beyondtitle,color,colors,widthandunitis dropped (offset, precision and visibility belong to the binding). Only a type check againsttaji.d.tscatches them.
What a write checks
indicators/write compiles source (a 422 compile lists diagnostics with lines), then runs it over a fixed fixture and reports per plot the na count, first bar, min, max and last, plus logs and ms. Three invariants must hold, each failing with the first differing row:
determinism: a second fresh instance gives bitwise the same rows.prefix: the history over the first half equals the first half of the full run.ticks_then_close: ticks of a forming bar, then its close, give the close alone.
If test is given it runs too: a module importing only @taji/indicators whose default export maps names to (t: T) => void, T from import type { T } from "@taji/indicators".
import type { T } from "@taji/indicators";
export default {
"a flat series is flat"(t: T) {
const r = t.run({ length: 14 }, Array(40).fill(10));
t.assert(r.rsi.length === 40, "one row per bar");
t.near(r.rsi[r.rsi.length - 1], 100, 1e-9, "no losses");
},
};
t.run(params?, closes?)answers{time, <plot>}as arrays.closesmakes bars with open = high = low = close and volume 0, 900 s apart; without it the fixture runs. Overclosesonlysourceinputs are fed (a field word reads the close,volume0): a script with an anchor ordatainput runst.run()on the fixture, or the test failsrun(closes) cannot feed anchor or data inputs.- A test cannot feed another indicator's plot: a
sourceparam of{binding, plot}failsinput <name>: a test cannot read another indicator's plot. t.assert(ok, message);t.near(a, b, tol, message).- A throw fails that one test. The file is stored beside the source and
indicators/testreruns it.
A refused write stores nothing: read the 422 report, fix, write again. indicators/check runs the same checks without storing.
Faults and budgets
A script that throws, runs past its budget or past memory is a fault, not a crash: its rows clear, the legend shows a red ! with the message and the bar time, and GET /get/indicators carries meta fault as JSON {kind, message, at, line, column} (kind threw, budget, memory or compile; at the bar's UTC seconds; each absent where unknown). Fix the source and write again; a bound indicator following the bare name picks up the new version. A budget fault means the script computed past its allowance (50 ms of CPU for setup or one step, 1 s for compile, history, or one test), counted on the script's own thread, so a busy machine does not cause it. The lane runs in the kernel's process: it bounds a script's CPU and memory, it does not contain a hostile script.
- History: 1 s for compile and the whole run.
- A tick: 50 ms.
- Memory: a 256 MB heap, and 256 MB of array buffers apart from it; past either faults
memory.
Limits
A write refuses, naming the limit:
name:[a-z][a-z0-9_], at most 64 characters, no built-in's;sourceandtestat most 256 KiB each.- The definition's
name(its legend title): 1 to 64 characters. - At most 32 inputs, 8
dataentries, 32 columns (a candle or a bar is four) and 16 fills. - Every input,
data, plot and fill name:[a-z_][a-z0-9_]{0,63}, each used once across all four.
A write, check or test holds the kernel's turn while it runs: four history runs of the fixture at 1 s each, 80 tick and close steps at 50 ms each, and 1 s per test, so the wait is bounded.
Versions
Every distinct write is the next version, immutable: <name>@1, @2. add_indicator {definition: "<name>", params: {}} follows the latest, "<name>@N" pins one. A write whose source and test equal the latest version's answers that version and stores nothing.
Inputs
inputs: { <name>: input.<kind>(default, options?) }. Every kind takes a trailing options object, Pine's keys beside the kind's own: title (the row's label), group (a heading over consecutive rows), inline (inputs sharing an id share a row, and must be declared together), tooltip (the ⓘ text), active (the name of a bool input that enables this one), confirm (time and price only, below). Strings of 1 to 64 characters, a tooltip to 1024. title falls back to the input's name in words.
| kind | options | reaches next as | the dialog draws |
|---|---|---|---|
input.int(d, {min?, max?}), input.float(d, {min?, max?}) | bounds | number | a number field |
input.bool(d) | boolean | a checkbox | |
input.choice(d, {options}) | the words | string | a select |
input.text(d) | string | a text field | |
input.color(d) | #rrggbb or #rrggbbaa | string | a colour swatch |
input.session(d) | HHMM-HHMM, e.g. 0930-1600 | string | two time fields |
input.interval(d) | an interval word: 5m, 1h, D, W, 3M | string | the interval menu |
input.symbol(d) | non-empty | string | a text field |
input.time(d?, {confirm?}) | UTC milliseconds, as Pine's input.time; no default only with confirm | number | a date and a time field in the display timezone |
input.price(d?, {confirm?}) | no default only with confirm | number | a number field stepping by the instrument's tick |
input.source(d), input.anchor(d, {at?}) | per bar (below) | a select |
confirm: true, Pine's interactive mode: adding the indicator in the window asks the user to click the chart for each confirm input (a time takes the clicked bar's open, a price the clicked price; a time and a price sharing an inline id, the only pair on it, are one click), and Escape adds nothing. Over MCP set them in add_indicator's params; a binding leaving a confirm input with no default unset is refused set <names>: no default; …. A time compares with bar.time * 1000.
A write refuses a malformed default, an active naming a missing or non-bool input and a split inline row, naming the input; a bound value breaking the same rules is refused naming it.
Inputs from the kernel
The manifest declares them; the kernel feeds them per bar.
source: input.source("close")is a number innext,inputs.source: the bar field the binding'ssourcenames (open high low close volume hl2 hlc3 ohlc4 hlcc4) or another indicator's plot on the same pane ({binding, plot}, the other's id). An alert's indicator operand takes the same{binding, plot}source, a binding on a chart of the alert's Desk on its symbol and interval: it reads that chart's instance, and still fires with the Desk off screen.anchor: input.anchor("session")is{starts, period_start}innext:startstrue on the bar the period starts and on the first bar,period_startits calendar start asyyyymmdd(the session's day, a week's Monday, the 1st of a month, quarter or year: it may be a holiday). Periods:session week month quarter year decade century, andtimewithatnaming atimeinput (input.anchor("time", { at: "start" })): one period from the first bar opening at or after that instant, never reset,period_startthat bar'sbar.time; before itstartsis false andperiod_startNaN. A write refuses anatnaming notimeinput.data: { htf: data.bars({ interval: "1h" }) }givesdata.htf.last({time, open, high, low, close, volume}), the newest1hbar closed by this bar's close, as Pine'slookahead_offon history (on an extended-hours equity chart aDor coarser read turns at the day's extended close, not the regular close; its bar is the regular session's), anddata.htf.changed, true whenlastis a different bar than on the bar before. Its fields are NaN before the first closes. Withoutintervalit is the interval the indicator computes on (the chart's, orcalc);symboldefaults to the chart's.data.bars({ interval, depth: 3 })addsdata.htf.at(k), the k-th closed bar beforelast(at(0)islast), NaN beyond history;depthis 1–500 (default 1, a write refuses more) and anat(k)past it throws.asof: "open"makeslastthe bar closed by this bar's open, Pine'srequest.security(sym, tf, expr[1], lookahead = barmerge.lookahead_on): it differs from the default exactly on the bar whose close completes a higher bar.data.htf.formingis the higher bar in progress as of this bar's close, the chart's own bars since its open folded ({time, open, high, low, close, volume},timeits open). It exists only where the chart's bars nest in the series' by the instrument's calendar (one symbol; 5m in 1h, not 7m in 1h; a regular-hours chart inD, not an extended-hours one); elsewhere reading it throwsdata.<n>.forming: the chart's bars do not nest in <interval>. History serves each bar's fold, as a replay ofrequest.security(sym, tf, close)shows it; reading it marks the bindingrepaints.data: { ltf: data.bars({ interval: "1m" }) }with an interval below the one the indicator computes on givesdata.ltf.intrabars: a frozen array of that interval's bars inside this bar ({time, open, high, low, close, volume}), oldest first, Pine'srequest.security_lower_tf; on a forming bar the ones closed so far and the forming one. Only where they nest in its bars by the instrument's calendar (one calendar: 1m or 5m in 1h, 1m inD, not 2m in 5m), else the binding faults. The newest 200,000 intrabars at most are served, and only whole: earlier bars, the bar holding the first held intrabar unless an intraday bar opens on it, and bars the store holds none for read an empty array..last,.changed,.at(k)and.formingon such an entry throwdata.<n>.<read>: <interval> is finer than the interval it computes on: read data.<n>.intrabars;.intrabarson any other throws.data: { divs: data.events("dividends") }givesdata.divs.last, the newest event knowable by this bar's close ({date, ...},dateasyyyymmdd; NaN before the first), anddata.divs.changed, true on the barlastbecomes a different event. Fields:dividendsamount;splitsratio_from,ratio_to;earningseps_estimate,eps_actual,eps_surprise,eps_surprise_pct(NaN where the source holds none). A dividend or split is served from the first bar of its ex date (it is announced ahead and trades ex at that open); an earnings report only once out: from 09:30 New York on its report date before the open, else from the next session, however early the row was fetched. So for an after-close reportdata.er.lastmoves a session after the Earnings anchor, which marks the report date's own bar. The binding waits withreading corporate actionsorreading earningsuntil the read lands; the write's fixture holds no events.data: { lv: data.product("taji-gex.levels", { lens: "vanna" }) }reads a plugin's product, or one of the hub'strades,option_flow,quotes,index_daily,statistics,imbalanceandstatus(symboldefaults to the chart's):data.lv.lastis its newest row knowable by this bar's close (every number NaN before one),.changedis true when it is a different row, and.rowsthe rows that became knowable inside this bar, oldest first, the newest 4,096 when more did. A row serves its number, decimal, instant (UTC seconds), date (yyyymmdd), bool and number-list columns and never a string. A word the product does not declare, a value out of its range,chainsanddepth(snapshots, many rows an instant) and a product with no knowable or time column are refused at write.statisticstakesstat, one ofopen,high,low,close,settlement,open_interest,cleared_volume,auction_open,auction_close,indicative,luld_upper,luld_lower,hv,iv,fee_rate,short_interest,short_volume,high_52w,low_52w,vwap,high_limit,low_limit,call_volume,put_volume,call_oi,put_oi,put_call_volume,put_call_oi,iv_rank,iv_percentile,iv_high_52w,iv_low_52w(another is refused), and its figure is.last.price;option_flowservescall,side,premium,strike,price,sizeand the rest of its numbers. A plugin script declares what it reads in its[[kernel.indicators]]row'sneeds. Types:ProductsandProductintaji.d.ts.data: ({ inputs }) => ({ htf: data.bars({ interval: inputs.tf }) })computes the entries from a binding's params, once per instance: a source input is its word or its{binding, plot}, an anchor input its period word, not the per-bar valuesnextsees.- Every indicator, built-in or yours, takes
calc(an interval word at or above the chart's: it computes on that series and shows on the chart's) andorigin(UTC seconds: it computes from the first bar at or after) inadd_indicator'sparams. They are not manifest inputs. Withcalc,calc_closestrue (the default: wait for timeframe closes) serves a calc bar's value only on the chart bar that closes it and null elsewhere; false serves the newest closed calc bar on every chart bar and the forming one on the live bar. A script's drawings undercalcare served on the chart's bars: an x at a calc bar's time on the chart bar at that time, one past the calc series counted in chart bars.
Faults on the binding, the message of GET /get/indicators' meta fault: data needs a live chart (a custom with data on a frozen pane), daily bars need a live chart (Prior Day Levels on a frozen pane), data <n>: interval <w>: … (a bad data interval), data <n>: <w> does not nest in the <w> it computes on, data <n>: <symbol> trades on another calendar than <symbol> (a finer interval on another calendar), calc <w> is below the chart's <w>, source: … (a plot source naming no indicator or plot on the pane, a cycle, or a source that faulted), no indicator <definition> (no plugin registers it and its Desk holds no such custom) and <plugin> is disabled: <reason>. The last two keep the binding and its saved record; it computes again on the pass after its definition returns.
The write's fixture feeds data too, but only D, W, M, Y and intraday intervals; an interval below its 15m holds no intrabars (an empty .intrabars on every bar) and must tile 15m (data <n>: interval <w>: does not nest in the fixture's 15m); a symbol reads the fixture itself.
Not built
Heikin Ashi and other non-standard bars (bars: chart), past and ta.hist (keep a value's history in state), drawn label tooltips (tooltip is stored and served), and any ta.* beyond sma ema rma rsi change crossUp crossDown (write it by hand, as references/pine.md says). Do not rely on them.
Worked example
call verb/desk/<id>/indicators/write {name: "rsi_ma_cross", source} with:
import { indicator, input, plot, ta } from "@taji/indicators";
export default indicator({
name: "RSI MA cross",
pane: "own",
inputs: { length: input.int(14), ma_length: input.int(9) },
plots: { rsi: plot.line(), ma: plot.line(), up: plot.marker({ shape: "triangle-up", at: "below" }) },
setup: ({ inputs }) => ({ rsi: ta.rsi(inputs.length), ma: ta.sma(inputs.ma_length), up: ta.crossUp() }),
next(bar, s) {
const rsi: number = s.rsi.next(bar.close);
const ma: number = s.ma.next(rsi);
return { rsi, ma, up: s.up.next(rsi, ma) ? rsi : NaN };
},
});