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.

Scripts panel listing an applied RSI indicator

Abstract

PieceRole
runScriptEngine invocation + status/timeouts
runAndApplyChart + lastRun + results open; may addIndicator
probeEndpointSettings health check helper
Scripts panel (IndicatorPanel)List / toggle / colors for store.scripts
IndicatorCardPer-script UI chrome

Language semantics: PYNE runtime.

Conceptual model

Diagram

Rendering…

Interface surface

runScript options

OptionDefaultMeaning
silentfalseQuiet status; live re-run logging
timeoutderivedInteractive: scales with bars (60–180s); silent 45s

runAndApply options

OptionDefaultMeaning
openResults!silentOpen results drawer
indicatorIdoptionalUpdate 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

PathRole
src/indicators/runner.tsPipeline
src/indicators/IndicatorPanel.tsxList UI
src/plugins/active.tsActive engine/source helpers
src/engines/catalog.tsBuilt-in engines
src/results/plot-visuals.tsPlot style → series kind

Invariants

  1. Runner is the only chart-facing calc orchestrator (avoid duplicate apply logic in components).
  2. Errors still setLastRun with status: 'error' when possible.
  3. Clearing overlays happens before re-adding—no unbounded series leak.
  4. AXIS does not interpret Pine; it only maps RunResult.

Failure modes

SymptomLayer
Engine exceptionResults error + status
Success empty plotsScript/meta—not runner
Manager nullChart not mounted; run still sets lastRun
AbortErrorTimeout—reduce bars or optimize script

See also