ChartnautDocs

Emit not collected

Your definition calls ctx.emit, but no events appear on the chart, after running the definition over history, or in a study. Every emit that does not become an event was either dropped with a reason or never reached. Find out which before you touch the condition.

Dropped emits

A definition's run counts each emit it drops, by reason:

Reason

Cause

Fix

unknown_event_id

The id passed to ctx.emit has no matching events.declare. The run also logs ctx.emit("id"): no matching events.declare.

Declare the event, or fix the spelling so both ids match.

missing_label

The emit has no label, or an empty one. The run logs ctx.emit("id"): label is required, and the lint warns with events/emit-missing-label.

Pass { label: "OR break up" } as the third argument.

dedupe_oncePer

The event declares oncePer: { keys: [...] } and an earlier emit had the same values for those keys.

Expected. Remove oncePer for per-bar events, or add a key that changes when you want another event.

warmup

The bar was inside the declared warmup. Warmup bars settle state and record no events.

Expected. Events start after the warmup.

oncePer dedupes over the whole run. Its windowBars option is not enforced by any runtime, so it cannot limit dedupe to a window. Do not build your own dedupe map in ctx.accum: the chart and the run over history would dedupe differently.

Checklist

  1. meta({ kind: "flow" }). Events exist only on definitions. A script with another kind never emits.

  2. Event declared. events.declare({ id, intent, payload }) with the same id ctx.emit uses. Every payload field needs { type, description }.

  3. Label on every emit. ctx.emit(id, payload, { label }). The label is the text on the chart and in research.

  4. Paint is not "none". paint: "none" records events but draws nothing on the chart. Omit paint, or use "pin".

  5. The condition fires. Log what the condition tests with ctx.log(...) and read the builder's Logs tab. A rare condition can be quiet on a short range; widen it before rewriting.

  6. The right version. Saving the definition makes a new version, and events are stored per version. A study pinned to an older version reads that version's events.

  7. The right profile, instrument, timeframe and range. Events are stored for the profile, instrument and timeframe they were run on, over that range. Run over history again with the ones you are checking. A timeframe outside runOn is refused with timeframe_not_allowed, and an omitted timeframe defaults to 1d.

  8. The study's alias. In a study, ctx.event.flow is the as you gave flows.declare({ as }), not the definition's slug. The lint flags a mismatch as study/event-flow-branch-mismatch.

Emits in timeframe handlers

ctx.emit inside a timeframe(...).onBar handler is refused with timeframe/no-output-in-handler. Keep the value in the handler's state and emit from the chart onBar, once per close:

const daily = timeframe("1d");

export function onBar(ctx) {
  if (!daily.closedThisBar || !daily.last) return;
  ctx.emit("day_close", { close: daily.last.close }, {
    label: "Daily close",
    price: daily.last.close,
  });
}

Minimal test emit

If you are not sure any emit gets through, replace the condition with one that fires on every bar:

meta({ name: "Emit test", kind: "flow" });

events.declare({
  id: "tick",
  intent: "diag",
  payload: { reason: { type: "string", description: "Why the test emit fired" } },
});

export function onBar(ctx) {
  ctx.emit("tick", { reason: "test" }, {
    label: "Test tick",
    price: ctx.close,
    timeStart: ctx.time,
  });
}

If this produces events, the problem is your condition. If it does not, check the kind, the version and the range you ran over.

What a study can read

A study reads each event's declared payload fields through ctx.event.payload. The emit's label and subtitle are for the chart and research only; a study never sees them. Put anything a study needs in the payload, and declare it in events.declare.

More on emits and labels: Emit and labels. Running a definition over history: Run a definition over history.