feature
Declaring indicator dependencies
Your script can depend on another indicator (for example ATR or VWAP) by declaring it once, then reading its values on ctx.indicators.
Use this whenever one script builds on another’s series. The declare shape is the same for indicators, definitions, and studies — always pin a version when you can.
Declare (same contract)
indicators.declare({
slug: "atr",
as: "atr",
version: 3,
settings: { /* optional locked settings */ },
});Field | Role |
|---|---|
| Indicator slug |
| Local alias on |
| Pin a version (always preferred; required on indicator/flow contracts) |
| Optional settings override |
Agents should call resolve_dependency_contract / request_add_indicator before inventing shapes.
Read — indicator & definition
function onBar(ctx) {
const atr = ctx.indicators.atr;
if (!atr) return;
const v = atr.value; // or atr.at(0), atr.last()
if (v == null) return;
ctx.plot("atr_copy", v);
}IndicatorView helpers
Method | Role |
|---|---|
| Current value |
| Offset bars |
| Last known |
| Recent history |
| Lifecycle query |
| Visual accessors |
Read — study
export function onEvent(ctx) {
const atr = ctx.indicators.atr?.atr; // output map + visual accessors
if (atr == null) return;
ctx.collect("atr", atr);
}Studies also declare upstream definitions with flows.declare — that is study-specific. See Study declarations.
Declared vs had-data
Empty values are normal (warmup, purge, MTF gaps). Guard explicitly — Dependency outputs.
