Spectra

Scripts

Un DSL de scripting, no un selector de indicadores.

Cinco tipos de script, acceso a ticks, vista previa y replay local, más un runtime aislado 24/7 para alertas enrutadas, todo en un lenguaje.

01 · Cinco tipos, un único lenguaje.

Cinco tipos, un único lenguaje.

Indicator, Alert, Screener, Drawing, Strategy. La sintaxis es compartida; cada tipo apunta a una superficie específica.

  • Indicator — Añade una serie u oscilador al gráfico. Vive en chart-preview, sin overhead.
  • Alert — Expresión booleana evaluada en cada cierre de vela. Push, email o webhook — tú eliges.
  • Screener — Devuelve los símbolos que cumplen una condición. Corre sobre una watchlist en un schedule.
  • Drawing — Formas programáticas en el gráfico — zonas supply/demand, FVGs, OBs, niveles personalizados.
  • Strategy — Código que emite órdenes. Backtestea contra el mismo motor de fills que corre 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

4 líneas. Pinta SMAs rápida/lenta y emite una señal booleana.

02 · Un DSL, tres runtimes.

Un DSL, tres runtimes.

Escríbelo una vez. Ejecútalo donde sea que se imprima un precio.

  • Vista previa del gráfico — Tecleas, ves dibujarse la línea al instante. El bytecode se recompila en cada tecla en menos de 80 ms.
  • Backtester — Mismo script, replay barra a barra con slippage realista en puntos básicos, comisión por fill, fills parciales y manejo de gaps.
  • Worker VPS — Marca un script con runs_on: vps y se dispara en un cloud worker 24/7 — alertas y órdenes webhook incluidas.
Slider comparando un gráfico de velas simples con el mismo gráfico tras dibujar un indicador de divergencia RSI escrito por el usuarioAntesDespués
Slider: gráfico simple ← arrastra → indicador personalizado de divergencia RSI
25s · escribe, guarda, mira cómo se dibuja

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 · Garantías del sandbox.

Garantías del sandbox.

Tu alerta no puede tirar tus gráficos. Cada script corre con presupuestos duros de CPU y memoria, aplicados a nivel de VM.

  • VM bytecode, no sandbox JS. Sin acceso al runtime host.
  • Presupuesto de CPU por script (default 50 ms) y techo de memoria (default 16 MB).
  • Tokens de cancelación — un script de larga duración puede matarse a media barra.
  • Sin paths `unsafe`. Sin acceso a archivos o red salvo built-ins auditadas.
20s · endurece el filtro, mira encogerse la lista

Escribe una vez. Opera en todas partes.

El lenguaje de estrategias completo más el cloud worker 24/7 — incluidos gratis para todo trader durante el lanzamiento.