reference
Sessions
Session helpers tell you when London, New York, or the trading day opens and closes — so you can key logic off session boundaries instead of raw clock math.
Indicators, definitions, and studies each expose a slightly different session API for the same idea. Use this when your setup is session-based (opens, overlaps, RTH vs ETH).
Indicator — isStart
if (ctx.session.isStart("london")) {
ctx.mark("ln_open", { price: ctx.open, text: "LN", time: ctx.time });
}Modes: consistent, daily, weekly, monthly, london, newyork, tokyo, sydney.
Definition — session object
export function onBar(ctx) {
const s = ctx.session({ /* SessionOpts — see IntelliSense */ });
if (s.didOpen) {
ctx.emit("session_open", { key: s.key }, {
label: `Open ${s.key}`,
timeStart: s.start,
price: ctx.open,
});
}
}Common fields: key, start, end, isOpen, didOpen, didClose, prev.
Study — key / bounds / bucket
ctx.session.key(t);
ctx.session.boundsOf(t);
ctx.session.bucket(t, "london");Use buckets with scopeEvent / indexedBy when tables or pins are session-scoped.
Common mistakes
Assuming New York session equals exchange RTH without checking opts
Emitting once-per-session logic without definition
oncePerUsing session helpers on weekly charts without
runOnlimits
