Getting started

What Vex is, and your first script.

For AI tools: this page as Markdown · the whole language in one file

Vex is BackQuant's language for chart indicators. You write formulas, then say what to draw; the chart works out the rest: the settings, where it draws, the colors. Scripts run in your browser on the chart's own bars, on every tick, and use BackQuant data (gex, oi, funding, ...) like any price.

A whole indicator

1name("My RSI")2 3length = 144 5gain = max(close - prev(close), 0)6loss = max(prev(close) - close, 0)7rsi = 100 - 100 / (1 + rma(gain, length) / rma(loss, length))8 9plot(rsi, "RSI", color = blue)10level(70, 30)
  • name("My RSI") names the script: the legend and the indicator list show it.
  • length = 14 is a plain number at the top, so it is a setting you can change on the chart.
  • prev(close) is the close of the bar before.
  • plot(...) draws a value. RSI isn't a price, so it gets its own pane.
  • level(70, 30) draws two dashed lines.

To run it: open the Script Editor (the SCRIPT command, or the code button on a chart's toolbar), write the script, and tick a chart under Add to chart. Each chart runs it with its own settings. Your scripts are also listed under My scripts in every chart's Indicators dialog.

See also: Settings, Drawing, Coming from Pine Script, Writing scripts with an AI