The indicators pane
Browse the indicator registry by category, set an indicator's parameters on sliders, and preview it over the picked slice's bars — a synchronous compute the pane asks the shell for, because the pane itself never touches the store.
crates/vike-studio/src/indicators.rs is the Studio's window onto the indicator registry. Its
header describes a pane that browses the single-series indicators, configures a selection's
parameters, and previews the computed series over the currently loaded bars; the browse and
compute helpers are pure and unit-tested, and the egui render is thin over them. The registry
itself, every indicator with its parameters and defaults, is the indicators
tree.
Browsing
The search box's hint reads "Search 171 indicators…" — the count the pane's header states for the
registry's single-series entries. grouped_search is the one list-building function: a
case-insensitive substring match over an indicator's short name and its pretty name (an empty
query matches everything), grouped by category in a fixed display order, skipping empty groups.
The order is CATEGORY_ORDER's — Trend, Momentum, Volatility, Volume, Statistics, Patterns,
Price, Structure — with the labels Category::label in crates/vike-indicators/src/registry.rs
gives them (the first is the Overlap category). It is a fixed array rather than a map because
Category is a plain discriminant enum with no ordering of its own.
Each group renders as an accent-coloured heading over selectable rows showing the pretty name; the
selected entry's pretty name and (short_name) sit above its parameters. A selection is stored by
name, so it survives re-filtering the search box.
Parameters
IndicatorsPane::select resets the parameters to the registry's defaults — default_params, in
the order the indicator's constructor takes them, and empty for parameterless indicators such as
vwap or obv — and clears any stale preview or error. Each parameter becomes a slider over the
registry's declared min..=max with its step and its name as the trailing label; the slider is
sized to the panel so a long parameter name cannot push the icon rail off-screen, which the pane's
comment records as exactly the over-wide row the old layout allowed.
Compute and preview
The Compute button returns true to the shell for one frame, and the shell does the rest —
IndicatorsPane::ui never touches the store, which is what keeps the pane's logic testable.
StudioState::compute_indicator_preview loads the picked slice's bars synchronously; the compute
is linear in the bar count and cheap, so unlike Run it needs no worker thread. Three refusals
surface as the pane's own error line:
- no slice picked — "pick a data slice first";
- a tick slice — "indicators need a bar slice — pick one from the Data combo", because indicators are bar-series maths;
- a load failure, with the store's message.
compute_indicator coerces the raw slider values against the parameter specs, builds a fresh
instance, and batch-computes it over the bars with vectorize — one output vector per declared
output line, empty vectors for empty input. The explicit coercion is cheap and idempotent even
though every registry constructor coerces internally; the registry's own doc asks external callers
to do it anyway. compute_indicator_matches_a_hand_computed_sma pins the result against a
hand-computed mean.
The preview is a 160-pixel plot, one line per output series named from the indicator's output list (falling back to the indicator's name), with NaN samples — the warm-up — filtered out of the points rather than drawn. Until Compute is pressed the pane says "Press Compute to preview."
Batch here, streaming in a strategy
What the pane previews is the batch vectorize path; a script calling the same indicator from
on_bar gets the streaming one, and whether the two agree is the indicators
index's subject. An indicator you write yourself in Rhai — writing an indicator
— is loaded from user_data/indicators/ per loading indicators;
crates/vike-model/src/state_path.rs's PROJECT_USER_DATA_DIR doc records that each such file
compiles to a real registry Indicator and is callable from a strategy as <name>().
Data and slices
The toolbar picker that lists every runnable series in the store — bars, then ticks — discloses what is recorded but cannot be replayed, and never lets a failed scan wear an empty store's clothes; and the Data tool that browses the whole inventory.
The templates gallery
Three starter Rhai strategies, each declaring its knobs with param() so it drops straight into the sweep grid — loadable blind from a dropdown, or previewed card by card in the gallery before they overwrite the editor.