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 |
|---|---|---|
| The id passed to | Declare the event, or fix the spelling so both ids match. |
| The emit has no | Pass |
| The event declares | Expected. Remove |
| 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
meta({ kind: "flow" }). Events exist only on definitions. A script with another kind never emits.Event declared.
events.declare({ id, intent, payload })with the same idctx.emituses. Every payload field needs{ type, description }.Label on every emit.
ctx.emit(id, payload, { label }). The label is the text on the chart and in research.Paint is not
"none".paint: "none"records events but draws nothing on the chart. Omitpaint, or use"pin".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.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.
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
runOnis refused withtimeframe_not_allowed, and an omitted timeframe defaults to1d.The study's alias. In a study,
ctx.event.flowis theasyou gaveflows.declare({ as }), not the definition's slug. The lint flags a mismatch asstudy/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.
