General FAQ

View as MarkdownOpen the editor

Short answers to the questions people ask most about wrun, each with a link to the page that has the details.

Getting started

What is a wrun indicator?

One file in TypeScript syntax. You write it in the chart's editor, Run draws it on your chart, and Publish shares it. It has no filesystem, no network and no order capability. Start with Your first indicator.

Do I need to know TypeScript?

About a page of it. The file is AssemblyScript: TypeScript syntax over fixed-width numbers (f64, i32), with no any and no dynamic typing. If you can read the Moving Average starter, you can write one.

Why does an indicator declare its outputs instead of drawing them?

The chart draws from the declarations, so one file computes the same way in your browser, in each reader's, on OpenMarket's servers and in alerts. What is wrun has the full picture.

Do files written with init, state, finalize and reset still work?

Yes, unchanged (Execution model).

Account, plans and support

Do I need a paid plan?

No. Every plan can write and run indicators, Free included; you need an account and a desktop browser. Plus raises the limits, and its price is on the Plus page.

Can I write an indicator on my phone?

No. The editor opens only in a desktop browser.

How do I reach the team?

Use Reach out in the app, or join Discord.

Data sources and context

How does an indicator know which market the chart shows?

It follows the chart: bar.close() and an unpinned input read the chart's own market and interval. To read a fixed market, pin a secondary input with symbol and exchange (Data sources).

Why is the start of my line empty?

Warm-up. TA classes return NaN until their window fills, and NaN draws nothing: a 200-bar average has no value on bar 50 (Execution model).

Can I read the previous bar?

Yes, with History from ./sdk/stats: push() once per bar, then ago(1) is the previous value (Stats, history and lists). There is no close[1]. By hand, keep the value in a module-level variable:

param("bars", 5, { min: 2, max: 50, description: "Bars in the trailing window" });
output("change", line, lower, { description: "Close minus the previous bar's close" });
output("window_high", line, overlay, { description: "Highest high of the trailing window" });

const MAX_BARS = 50;
const highs = new StaticArray<f64>(MAX_BARS);
let n: i32 = 5;
let cursor: i32 = 0;
let count: i32 = 0;
let prevClose: f64 = NaN;

function onStart(): void {
  n = i32(p_bars());
}

function onBar(): void {
  const close = bar.close();
  // The previous close is whatever we kept from the previous call: there is no close[1] to read.
  const change = isNaN(prevClose) ? NaN : close - prevClose;
  prevClose = close;
  highs[cursor] = bar.high();
  cursor = (cursor + 1) % n;
  if (count < n) count += 1;
  if (count < n || isNaN(change)) return;
  let h = -Infinity;
  for (let i = 0; i < n; i++) if (highs[i] > h) h = highs[i];
  out_change(change);
  out_window_high(h);
}
BTCUSDT perpetual on Binance, 1 hour bars, Aug 10 to Aug 18, 2026Real output from OpenMarket's engine

Can I analyze multiple markets in one indicator?

Yes: one pinned ohlcv input per market, with symbol and exchange together. The first input stays unpinned and sets the bar grid. Trades, funding, open interest and liquidations always read the chart's own market. Stocks, forex and gold pin the same way (Stocks, forex and gold).

// The first input is the grid: it follows the chart's own market.
input("close", ohlcv.close);
// Pinned inputs read fixed markets; symbol and exchange always pin together.
input("btc_close", ohlcv.close, { symbol: "BTCUSDT", exchange: "BINANCE_FUTURES" });
input("eth_close", ohlcv.close, { symbol: "ETHUSDT", exchange: "BINANCE_FUTURES" });
output("eth_btc", line, lower, { description: "ETH priced in BTC" });
output("vs_btc", line, lower, { unit: "%", description: "This market's close as a percent of BTC's" });

function onBar(): void {
  const btc = in_btc_close();
  if (isNaN(btc) || btc <= 0.0) return;
  out_eth_btc(in_eth_close() / btc);
  out_vs_btc((bar.close() / btc) * 100.0);
}

Can I write an indicator without a data source?

It always runs on the chart's own candles, even with no input(...) line, but it needs at least one output(...).

Can I declare inputs inside if, a loop, or a function?

No. Declarations are top-level statements, read before anything runs, so there are no conditional inputs.

How do I read the order book?

Declare a celled book input after the first input and scan its [price, size, side] tuples in onBar(): input("book", book.cells, { max_cells: 1000, block_size: 10 }). The chart serves up to 500 levels a side, so max_cells must cover 1,000 tuples. Order flow has worked scans.

How does an indicator handle data gaps?

Each input declares a missing policy: a secondary input repeats its last value by default ("carry"), "nan" gives NaN and "zero" gives 0. Lines never interpolate across NaN. For your own fill, handle it in onBar():

input("close", ohlcv.close);
// A sparse feed: bars with no liquidation deliver NaN instead of repeating the last value.
input("liqs", liquidations.liquidations, { missing: "nan" });
output("liq", line, lower, { description: "Liquidation volume this bar, 0 on quiet bars" });
output("last_liq", line, lower, { description: "The most recent liquidation volume, carried forward" });

let lastLiq: f64 = NaN;

function onBar(): void {
  const x = in_liqs();
  let liq: f64;
  if (isNaN(x)) {
    liq = 0.0; // your own zero policy
  } else {
    liq = x;
    lastLiq = x; // your own forward fill
  }
  out_liq(liq);
  out_last_liq(lastLiq);
}
BTCUSDT perpetual on Binance, 1 hour bars, Aug 10 to Aug 18, 2026Real output from OpenMarket's engine

On the primary input, "nan" and "zero" also turn a sparse feed into one row per bar (Data sources).

Technical indicators

Why am I getting NaN in my calculations?

Usually a TA class still warming up, a division by zero, or a missing: "nan" input on an empty bar. Test with isNaN(x), then skip the bar, write NaN, or substitute a value (Best practices).

Which TA classes exist?

52 in ./sdk/ta (Sma, Ema, Rsi, Atr, Bb, Macd and more) on the TA library, and 30 more in ./sdk/ta-plus on Extra indicators.

How do I use a param as a period?

Cast it in onStart(): sma = new Sma(i32(p_period())). Params are f64, periods are i32.

Plotting and visualization

How do I draw several lines on the same chart?

One output(...) per line: overlay on the price pane, lower in its own pane (Plotting).

Can I plot conditional signals?

Yes. A shape output draws only on bars where the output named in shape_where is nonzero:

param("len", 14, { min: 2, max: 200 });
param("level", 30, { min: 5, max: 50, description: "RSI at or below this counts as oversold" });
output("rsi", line, lower, { color: "#a78bfa" });
// The mark sits at the output's value (this bar's low) and draws only on bars where the gate is 1.
output("buy", shape, overlay, { color: "#22c55e", shape_where: "oversold" });
output("oversold", none);

let rsi = new Rsi(14);
let level: f64 = 30.0;

function onStart(): void {
  rsi = new Rsi(i32(p_len()));
  level = p_level();
}

function onBar(): void {
  const value = rsi.update(bar.close());
  if (isNaN(value)) return;
  out_rsi(value);
  out_buy(bar.low());
  out_oversold(value <= level ? 1.0 : 0.0);
}
BTCUSDT perpetual on Binance, 1 hour bars, Aug 10 to Aug 18, 2026Real output from OpenMarket's engine

How do I change plot colors dynamically?

Give the output a colors palette and name a data-only output in color_by; each bar's value picks the color:

param("fast", 10, { min: 1, max: 200 });
param("slow", 30, { min: 2, max: 400 });
// Each bar's trend value (0 or 1) indexes the palette: red below the slow average, green above.
output("price", line, overlay, { width: 2, color_by: "trend", colors: ["#ef4444", "#22c55e"] });
output("trend", none);

let fast = new Sma(10);
let slow = new Sma(30);

function onStart(): void {
  fast = new Sma(i32(p_fast()));
  slow = new Sma(i32(p_slow()));
}

function onBar(): void {
  const close = bar.close();
  const f = fast.update(close);
  const s = slow.update(close);
  if (isNaN(s)) return;
  out_price(close);
  out_trend(f > s ? 1.0 : 0.0);
}
BTCUSDT perpetual on Binance, 1 hour bars, Aug 10 to Aug 18, 2026Real output from OpenMarket's engine

Can I write an output inside a conditional or a loop?

Yes. Each output holds one value per bar and the last write wins. Write NaN, or skip the write, to draw nothing on a bar.

What is the difference between line, area, histogram and scatter?

Only the look: line joins the points, area fills under them, histogram and bar draw columns, scatter draws points. candle draws four outputs as a candle, shape draws a gated mark, and none computes without drawing (Plotting).

How does positioning work for shapes and text?

A shape draws at its value on its bar, so write the bar's low or high to place it. Text comes from string slots: render.text draws one mark per bar, render.label one label (Drawing objects).

My line hugs the bottom of the price chart

It is a small-number series on the price axis. Declare it lower.

My box draws with no fill

Its opacity is 0; the default is 0.2.

My mark draws on every bar

Add a data-only gate output, name it in shape_where, and write 0 to it on quiet bars.

Common issues and troubleshooting

My indicator isn't displaying anything

Check, in order:

  1. The editor's Console: a failed build draws nothing, and it says when an output was NaN on every bar.
  2. Whether onBar() reaches its writes: a TA class short of bars returns NaN.
  3. Whether the output is declared none.
  4. Whether the chart's market serves the input's source: the legend shows Could not load.
  5. Whether a pin was refused.

Debugging has the full workflow.

Undefined identifier errors

Cannot find name 'out_sma' means the declaration was renamed, removed or misspelled. Accessors are generated from declaration names, lowercased, with other characters turned into _: param("fast.len", ...) is p_fast_len().

How do I debug my indicator?

Three ways in the editor: print lines with a debug string slot, read values at the Console prompt after a Run, or declare the suspect value as an output (Debugging).

Why isn't my indicator updating in real time?

It is, about once a second: the forming bar runs again on live updates, without double-counting. Polled sources (open interest, implied volatility, ETF flows) move when their poll lands. A draft stops on reload: Run it again.

Can I use null instead of NaN for missing data?

No. Outputs are f64, which has no null: NaN means "nothing here" and draws a gap, while 0 draws a zero.

The chart refuses my symbol or interval pin

Pins have rules:

  • A market pin goes only on a secondary ohlcv input, and never on a CME Group venue.
  • An interval pin must be coarser than the chart and a whole multiple of it.
  • The first input takes no pin.

The Console names the refusal (Limitations, Multi-timeframe, exchange ids).

Language features and syntax

Does it support switch statements?

Yes, over integers, with TypeScript's fallthrough rules (write break). Bucket a float into an integer first:

param("len", 14, { min: 2, max: 200 });
output("score", line, lower, { description: "-1 oversold, 0 neutral, 1 overbought" });

let rsi = new Rsi(14);

// A switch runs over integers: bucket the value first, then branch. Each case breaks.
function zone(value: f64): i32 {
  if (value <= 30.0) return 0;
  if (value >= 70.0) return 2;
  return 1;
}

function onStart(): void {
  rsi = new Rsi(i32(p_len()));
}

function onBar(): void {
  const value = rsi.update(bar.close());
  if (isNaN(value)) return;
  let score: f64 = 0.0;
  switch (zone(value)) {
    case 0:
      score = -1.0;
      break;
    case 2:
      score = 1.0;
      break;
    default:
      score = 0.0;
      break;
  }
  out_score(score);
}
BTCUSDT perpetual on Binance, 1 hour bars, Aug 10 to Aug 18, 2026Real output from OpenMarket's engine

Are objects and arrays supported?

Yes, with static types: StaticArray<f64> for fixed windows, Array<f64>, Map, and classes with typed fields. Allocate in onStart(), never in onBar() (Collections, User-defined types).

Can an indicator read another indicator's values?

No. Combine the logic into one file.

Can I use inputs and TA classes inside my own functions?

Yes: readers such as bar.close() work in any function onBar() calls, and a TA class is an ordinary object. Functions cannot capture locals, so keep shared state at module level (User functions).

Does it support alerts?

Yes. Publish the indicator, add it to a chart, and open the alert dialog from its bell in the legend to pick an output and a condition. The file can also define a ready-made signal with alert(...). Alerts run in OpenMarket's cloud (Alerts).

Can trades be executed from an indicator?

No. An indicator has no order capability. A strategy places orders only in the Strategy Tester's simulation (Strategies overview).

Can I show text?

Yes, through a string slot and a renderer: render.label, render.text or render.table (Drawing objects).

Can I move or delete a shape after drawing it?

Yes, with a drawing handle (a line, box, label or polyline) that you update or delete by id (Drawing objects).

How many shapes can I have?

16 declared boxes and 16 segments, up to 1,000 live drawing handles per kind (1,500 in all), and 2,000 drawings per run. Limits has every cap.

Performance and optimization

My indicator is running slowly. How can I optimize it?

Cut the per-bar work:

  • Allocate buffers once, in onStart(), sized from a param's max; never new in onBar().
  • Bound loops by a param with a max.
  • Compute a value once and reuse it.

Should I use const for constants?

Yes. A module-level const costs nothing per bar and can size a StaticArray. A value that depends on a param is a module-level let set in onStart().

Common error messages

Conversion from type 'f64' to 'i32' requires an explicit cast

You passed a float where a whole number is needed (a period, loop bound or index). Cast it with i32(p_period()), and declare floats as f64. Common errors lists every message with its fix.

Still have questions?