DocsSoma Node

Soma Node

A fully programmable graph node that runs custom indicator logic written in the Soma scripting language — a purpose-built DSL for time-series computation. Declare typed inputs, outputs, and parameters directly in the script; the node compiles and re-executes on every graph evaluation.

Scripting DSLArray-first Float64ArrayCompile-cached IRLive IntellisenseSyntax HighlightingBuilt-in Indicators40+ Math FunctionsConfigurable Params

Node Data Shape

All Soma state is stored in node.data as a SomaNodeData object. The React Flow widget is styled indigo — one dynamic input handle per declared input, one output handle when at least one output is declared.

interface SomaNodeData {
  label:       string;
  somaCode:    string;              // raw script source

  inputs:      SomaInputDef[];      // { name, type } — re-parsed on each compile
  outputs:     SomaOutputDef[];     // { name, type }
  params:      SomaParamDef[];      // { name, type, default? }
  paramValues: Record<string, number>; // user-overridden runtime values

  _compiled?:  SomaIR;             // cached IR — reused when source hash matches
  _codeHash?:  string;

  resultData?: Record<string, Float64Array | number | null> & { timestamps?: number[] };

  enabled?:    boolean;
  visible?:    boolean;
  stacked?:    boolean;
  isLoading?:  boolean;
  error?:      string | null;
}

Quick Example

The default script computes Bollinger Bands. Wire the close price series to the prices input handle and the node emits three output series: upper, mid, lower.

# Bollinger Bands
input  prices
param  period as int = 20
param  mult   as float = 2.0
output upper
output mid
output lower

let m = sma(prices, period)

for (i, v) in prices {
  if i < period - 1 { continue }
  let mean = m[i]
  let d = 0.0
  let j = 0
  while j < period {
    let diff = prices[i - j] - mean
    d = d + diff * diff
    j = j + 1
  }
  let sigma = sqrt(d / period)
  mid[i]   = mean
  upper[i] = mean + mult * sigma
  lower[i] = mean - mult * sigma
}

In This Section