Skip to main content
Know the limits a script runs within. They are the same on every device and every plan. Past the step budget a script stops with OX2200, naming the line of the loop or call, and keeps what it had drawn. Counting steps rather than time makes the limit behave the same on a phone and a desktop. A run that takes more than 5 seconds is stopped, and the same script with the same settings is not loaded again on the page until you change it.

Keeping a script fast

  • Work per bar, not per bar times history: keep running totals in state rather than looping back over old bars.
  • Draw only on the newest bar (chart.isLast) when only the newest bar’s drawing matters.
  • Sum events into tallies in their handlers; do the per-bar work once in onBar or onClose.

The same result everywhere

A script gives the same output for the same data in every browser:
  • no clock, timers or Math.random: random(seed) gives the same numbers for the same seed;
  • Math is the engine’s own, a port of fdlibm, so exp, log, pow and the trigonometric functions give the same bits in Chrome, Safari and Firefox;
  • ta.* follow TradingView’s formulas, seeds and running sums.
Scripts run in a worker of their own, served with a policy that allows no network access, and output is checked against the script’s declaration before it is drawn.

Next step

Check scripts outside the terminal, or have an AI write them, with tools for agents.
Last modified on October 16, 2026