What is wrun

View as MarkdownOpen the editor

wrun is OpenMarket's engine for your own market logic. Write an indicator in TypeScript syntax, and wrun runs it on every bar of the real market, compiled to WebAssembly, right in your browser.

  • Compiled, not interpreted. A 20-bar average over 10,000 bars computes in under a millisecond.
  • Live without the lag. A live update re-runs one bar, never your whole history.
  • Nothing new to learn. TypeScript syntax your AI already writes, checked by a real compiler before anything runs.
  • The whole market. The order book, trade tape, liquidations and options chains, plus 78 built-in indicators and stats to build on.

How it works

How wrun works: market data goes into your indicator, which runs on every bar, and your chart draws what it writes.{ }Market dataCandles, trades,order book, optionsYour indicatorTypeScript syntax,runs on every barYour chartLines, boxes, labelsand alerts
  1. Market data. The file reads the data the chart serves, for the market on screen or another one (What you can read).
  2. Your indicator. One file, written in the chart's editor. There is nothing to install: Run compiles it in your browser, and its onBar() runs once per bar.
  3. Your chart. The chart draws whatever the file writes (What the chart shows). Once published, anything it draws can trigger an alert. A strategy also places simulated orders in the Strategy Tester; wrun never places real ones.

What a file looks like

The file and what it makes: param adds the Period setting, output adds the sma line, a variable outside a function keeps state between bars, onStart() runs once and onBar() runs on every bar.param("period", 20, { … });output("sma", line, overlay, { … });let sma = new Sma(20);function onStart(): void { … }function onBar(): void {out_sma(sma.update(bar.close()));}settingoutputstateruns onceruns every barPeriod20sma64,210.5
  1. Declarations come first. param adds a setting, here the Period field; output adds something to draw, here the sma line and its legend entry.
  2. State is any variable outside a function. It keeps its value from one bar to the next.
  3. onStart() runs once, before the first bar. Here it sizes the average from the Period setting.
  4. onBar() runs once per bar. Here it feeds the close into the average and writes the result.

The whole file, ready to paste into the editor:

param("period", 20, { min: 1, max: 200 });
output("sma", line, overlay, { color: "#2563eb", width: 2, description: "20-period simple moving average" });

let sma = new Sma(20);

function onStart(): void { sma = new Sma(i32(p_period())); }
function onBar(): void { out_sma(sma.update(bar.close())); }
BTCUSDT perpetual on Binance, 1 hour bars, Aug 10 to Aug 18, 2026Real output from OpenMarket's engine
  • The kit. Sma comes from the kit, the library of ready-made pieces every file can use by name with nothing to import: Rsi, Cvd, levels, market structure and more (Quick reference).
  • The language. TypeScript syntax over typed numbers (f64, i32); the dialect is AssemblyScript, so there is no any and no npm. If you can follow this file, you can write one: the Moving Average starter is this file with a comment on every line.

Bar by bar

Bar by bar: onBar() runs once for every bar, oldest first, and each run adds one point to the line; the circled forming bar at the right runs again as new data arrives.onBar()oldest barforming bar
  1. onStart() runs once, before any bar.
  2. onBar() runs once per bar, oldest first, over every bar the chart has loaded.
  3. State carries forward. Each call sees only its own bar. To use an earlier bar, keep it in a variable.
  4. Each call writes one value, and the chart joins the values into the line. A bar where nothing is written stays blank.
  5. The forming bar re-runs as new data arrives. Each run starts from the state of the last closed bar, so nothing counts twice.

Where it runs

Where an indicator runs: in your browser when you press Run, in each reader's browser when published as Hidden or Open source, and on OpenMarket's servers when published as Never leaves OpenMarket; the locks mark the sandboxed browsers, and alerts run in OpenMarket's cloud.Your browserRun draws a draftthat only you see.Readers' browsersPublished as Hiddenor Open source.OpenMarket's serversPublished as Neverleaves OpenMarket.Alerts on a published indicator run in OpenMarket's cloud.
  1. Run draws a draft on your chart for this session. It runs in a sandbox in your browser: no internet, no files, no access to your account.
  2. Publish with Compiled or Open source code gives the indicator a name (@yourname/name) and a version, and it runs in the same sandbox in each reader's browser, so adding someone else's indicator is safe. Compiled keeps the code to you: readers get a compiled module, never the source.
  3. Publish as Protected runs it on OpenMarket's servers. The code never leaves them; the chart shows the result.
  4. Alerts on a published indicator run in OpenMarket's cloud, wherever the indicator runs.

A published version never changes, and you choose who can use it: Everyone, Invite only, or Just me (Sharing).

Next