feature
Bull bar
Marks every bar that closes above its open. Payload carries bar range for later studies.
What it defines
A Collectable event bull_bar whenever close > open.
Key decisions
Piece | Why it matters |
|---|---|
| Enables emit / Collect (not an indicator). |
| Contract for Collect and studies. |
Required | Events without labels are dropped at runtime. |
Early | Keep |
Full script
meta({
name: "Bull bar",
kind: "flow",
slug: "bull-bar",
shortName: "BullBar",
});
events.declare({
id: "bull_bar",
intent: "Mark closes above open",
payload: {
range: { type: "number", description: "High minus low" },
close: { type: "number", description: "Close price" },
},
paint: "pin",
});
outputs.declare({
id: "close_line",
kind: "line",
name: "Close",
color: "#64b5f6",
});
export function onBar(ctx) {
ctx.plot("close_line", ctx.close);
if (ctx.close <= ctx.open) return;
const range = ctx.high - ctx.low;
ctx.emit(
"bull_bar",
{ range, close: ctx.close },
{
label: `Bull · R=${range.toFixed(2)}`,
subtitle: `close ${ctx.close.toFixed(2)}`,
price: ctx.close,
timeStart: ctx.time,
}
);
}