Scripts (indicators & strategies)
AXIS applied-scripts UI: runAndApply pipeline, Scripts panel, overlay routing, and engine binding.
This page
Scripts (indicators & strategies)
In AXIS, scripts applied to the chart may be Pine indicator() or strategy() definitions. The product panel is labeled Scripts (panel id remains indicators for workspace compatibility). The module boundary is indicators/runner.ts plus list UI—not the PYNE evaluator.
Abstract
| Piece | Role |
|---|---|
runScript | Engine invocation + status/timeouts |
runAndApply | Chart + lastRun + results open; may addIndicator |
probeEndpoint | Settings health check helper |
Scripts panel (IndicatorPanel) | List / toggle / colors for store.scripts |
IndicatorCard | Per-script UI chrome |
Language semantics: PYNE runtime.
Conceptual model
Rendering…
Interface surface
runScript options
| Option | Default | Meaning |
|---|---|---|
silent | false | Quiet status; live re-run logging |
| timeout | derived | Interactive: scales with bars (60–180s); silent 45s |
runAndApply options
| Option | Default | Meaning |
|---|---|---|
openResults | !silent | Open results drawer |
indicatorId | optional | Update existing store indicator |
Overlay routing
overlay = resolveOverlayFlag(meta.overlay, script_type)
// explicit false → sub-pane
// explicit true → price
// missing: indicator → sub-pane; strategy → price
if overlay && seriesWouldHideOnPrice(plots, bars):
overlay = false // RSI / scaled oscillators on BTC scale
paneId = overlay ? 'price' : `ind_<scriptId>` // one sub-pane per script
Each non-overlay script gets its own sub-pane (ind_<id>), not a shared indicator host. Re-runs keep the script’s private pane; legacy shared indicator panes migrate on re-run. Removing a script clears only that owner’s series and destroys the sub-pane only when empty.
Persist + reopen
Applied scripts (store.scripts with full code, paneId, colors, inputs, strategy props) are written to localStorage with the rest of durable UI state. On boot they hydrate via sanitizePersistedScripts. After each successful history paint (load-symbol, DSM cache apply), reapplyChartScripts silently re-runs every visible script in plot-dependency order so the chart matches the saved set without manual re-run.
Detach path: detachIndicatorFromChart (Scripts panel, Layers, pane badges) — owner-scoped overlay clear, orphan pane sweep, no sibling wipe.
Prefer indicator(..., overlay=false) and raw plot(rsi) for oscillators — not strategy(..., overlay=true) with rsi * 0.01 on price.
Series selection
Prefer result.series entries whose keys do not start with _ / __. Fallback: single plots[] array as one line named from script_name.
Colors: plot_meta[k].color or PLOT_PALETTE[i]. Pine Script™ plot.style_* maps to LWC series kinds (line, stepline, histogram/columns, area, circles) — see Charting — plot style parity.
Indicator panel & pane badges
- Side list of
store.scripts(Indicator: id, name, code, paneId, visible, plots) - Visibility toggles affect display; re-run is still engine-driven
- Chart pane chips mirror settings / eye / re-run / remove (see Charting)
Active engine binding
// plugins/active.ts pattern
getActiveEngine() // registry lookup by activePlugins.engine
getActiveEngineConfig() // pluginsConfig + store.endpoint merge
Switching engines mid-session does not auto-rerun; operator hits Run.
Live re-run coupling
Streams may set live.needsRerun; multiplex/runner path can call runAndApply with silent: true so the status bar is not spammed. Failures go to logs.
Internals
| Path | Role |
|---|---|
src/indicators/runner.ts | Pipeline |
src/indicators/IndicatorPanel.tsx | List UI |
src/plugins/active.ts | Active engine/source helpers |
src/engines/catalog.ts | Built-in engines |
src/results/plot-visuals.ts | Plot style → series kind |
Invariants
- Runner is the only chart-facing calc orchestrator (avoid duplicate apply logic in components).
- Errors still
setLastRunwithstatus: 'error'when possible. - Clearing overlays happens before re-adding—no unbounded series leak.
- AXIS does not interpret Pine; it only maps
RunResult.
Failure modes
| Symptom | Layer |
|---|---|
| Engine exception | Results error + status |
| Success empty plots | Script/meta—not runner |
| Manager null | Chart not mounted; run still sets lastRun |
| AbortError | Timeout—reduce bars or optimize script |