/** * A compiled program as a chart's indicator descriptor. * * The whole of the mapping is here in one function, because the mapping is the * adapter: every other file in this module is one column of the table this * assembles. `compiled-program.md` 11 writes that table out, and the shape of * this function follows it line for line. * * **The calculation drives the engine and computes nothing.** A descriptor's * `calc` is the chart asking for one column per plot; the engine already * produces exactly that, one channel at a time, so `calc` loads a program, runs * the bars and reads the channels out. Nothing here knows what a moving average * is, and that is the point: a second implementation of any of it would be a * second thing to keep in step with the specification. * * **The hooks that follow a calculation read it and do not repeat it.** Markers, * the grids, the drawing objects and each alert's message channel are taken once, * while the engine is in hand, and left in the run record `produced.ts` keeps. * The chart calls each hook after every calculation, so asking twice gives one * answer and a study with a grid costs the same over a hundred thousand bars as * over ten. A message is the channel itself rather than a copy of it: an alert * asks about one bar, and building a column of strings to answer that would cost * the history. * * **A declaration option written as an `input()` is resolved against the * settings the host states, not against the default.** That is the whole point * of writing one: `study("S", precision = input(2, "Places"))` is how a reader * changes something the declaration decides. The declared shape is fixed before * bar 0 and every field of it is a value rather than a call, so the settings * have to be in hand when it is built; `ChartAdapterOptions.settings` is where * they come from, and a descriptor built without them reads every such field at * its declared default. Which parts of the descriptor are resolved here and * which are asked for again per call is recorded in * `spec/chart-narrowings.json` and measured by * `scripts/check-chart-surface.mjs`. * * **The id is the source hash, not the title.** A saved layout stores the * descriptor id and the settings, and two scripts can easily share a title while * an edited script keeps the one it had. Hashing the source means the same * script restores to the same study and an edited one does not silently inherit * the settings of the study it replaced. A host that manages its own script * identities passes its own id instead. */ import type { CompiledProgram } from '../../core/emit/index.js'; import type { ChartDescriptor } from './contract.js'; import type { ChartAdapterOptions } from './run.js'; export declare function descriptorFor(program: CompiledProgram, options?: ChartAdapterOptions): ChartDescriptor; //# sourceMappingURL=descriptor.d.ts.map