Spectra

Scripting

A scripting DSL, not just an indicator picker.

Five script kinds, tick-level market access, local preview and replay, plus a sandboxed 24/7 server runtime for routed alerts — all in one language.

01 · Five kinds, one language.

Five kinds, one language.

Indicator, Alert, Screener, Drawing, Strategy. The syntax is shared; each kind maps to a specific surface.

  • Indicator — Adds a series or oscillator to the chart. Lives in chart-preview, ships zero-overhead.
  • Alert — Boolean expression evaluated on every bar close. Push, email, or webhook — your choice.
  • Screener — Returns the symbols that match a condition. Runs across a watchlist on a schedule.
  • Drawing — Programmatic shapes on the chart — supply/demand zones, FVGs, OBs, custom levels.
  • Strategy — Order-emitting code. Backtests against the same fill engine that runs live.
golden-cross.spec
// @spectra-script 2
let fast = ta.sma(close, 20)
let slow = ta.sma(close, 50)

plot.line("Fast", fast, color = color.teal)
plot.line("Slow", slow, color = color.orange)
output close > fast and fast > slow

Spectra Script v2 plots both averages and returns a boolean signal.

02 · Same DSL, three runtimes.

Same DSL, three runtimes.

Write it once. Run it everywhere a price prints.

  • Chart preview — Type, see the line draw immediately. Bytecode is recompiled on every keystroke under 80 ms.
  • Backtester — Same script, replayed bar-by-bar with realistic slippage in basis points, commission per fill, partial fills, and gap handling.
  • VPS worker — Tag a script with runs_on: vps and it fires on a 24/7 cloud worker — alerts and webhook orders included.
Drag-slider comparing a plain candlestick chart with the same chart after a user-written RSI-divergence indicator plots on itBeforeAfter
Slider: plain chart ← drag → custom RSI-divergence indicator
25s · type, save, see it plot

03 · Tick scripting

React to the market one execution at a time.

Spectra Script v2 exposes the retained trade tape and a true per-print callback. Use it to inspect aggressor flow, dollar size, delta, print counts, and the largest execution without reducing the tape to candle closes.

  • feed.tap(feed.trades) returns a bounded, newest-first execution window.
  • on_trade(price, size, is_buy, ts) runs once for every valid print in timestamp order.
  • Live tape retains 60 seconds and up to 10,000 prints; archive replay covers up to 24 hours and 10,000 prints.
  • Unknown aggressor sides remain visible and are excluded from directional aggregates instead of being guessed.
whale-flow.spec
// @spectra-script 2let minimum_usd = param.float("Minimum USD", 5000000.0, min = 1.0)fn on_trade(price, size, is_buy, ts) {  alert.wire(    "whale_buy",    is_buy and price * size >= minimum_usd,    message = "Large aggressive buy"  )}output false

True trade callbacks · bounded state · deterministic replay

04 · Server runtime

Keep approved alerts running after you close the app.

Save an alert with a target symbol and timeframe, then route it to the server worker. Bar scripts execute on completed intervals; tick handlers receive the real aggressor stream in bounded 50 ms scheduler batches.

  • Independent per-script state with tenant isolation and persisted fire timestamps.
  • Hard CPU, memory, loop, and recursion budgets plus cancellation on overrun.
  • Cooldown enforcement, runtime error capture, metrics, alert events, and outbound delivery.
  • Strategies remain preview/backtest workflows; unattended server execution is deliberately limited to alert scripts.
server-breakout.spec
// Runs on the saved symbol + timeframelet baseline = ta.sma(close, 200)let active = close > baseline and volume > ta.sma(volume, 20) * 1.5alert.wire(  "volume_breakout",  active,  message = "Volume breakout confirmed")output active

Route: VPS or Both · symbol + timeframe required

05 · Sandbox guarantees.

Sandbox guarantees.

Your alert can't take down your charts. Every script runs under hard CPU and memory budgets, enforced at the VM level.

  • Bytecode VM, not a JS sandbox. No access to the host runtime.
  • Per-script CPU time budget (default 50 ms) and memory ceiling (default 16 MB).
  • Cancellation tokens — a long-running script can be killed mid-bar.
  • No `unsafe` paths. No file or network access except via vetted built-ins.
20s · tighten the filter, watch the result list shrink

Write once. Trade everywhere.

The full strategy language plus the 24/7 cloud worker — included free for every trader during launch.