Skip to content
Nexus Prop LLC

NexuScript 1.5

NexuScript syntax reference.

Every keyword, operator, type, built-in value and function of NexuScript 1.5, with its parameters, what it returns, how it treats missing values, the errors it can raise and an example you can paste into the script editor.

How to read an entry

  • Syntax shows each parameter as name::Type. = value is the default when you leave it out; automatic means the function picks a sensible value for you. A parameter marked fixed must be the same on every bar (a number, an input or a constant).
  • Give arguments by position or by name: plot("Fast", fast, color = color.blue). Positional ones come first.
  • NexuScript 1.N is the version that added the name. A script that uses it starts with nexscript 1.N or later.
  • Times are milliseconds since 1970-01-01 UTC unless an entry says otherwise. Error codes such as NS420 are listed under each entry and explained in full where the script editor shows them.

Script structure

The header, the declaration, settings and the block that runs on every bar.

Statements and control flow

Variables, decisions, loops and functions.

Operators

Arithmetic, comparison, logic and text. Operators bind from the loosest (? :) to the tightest (^, then calls and [ ]).

Types and literals

Every value has one of these types. There are no hidden conversions.

Bar values

The prices, volume and time of the bar being run, and where it sits in the chart.

Time and sessions

Bar times, the exchange and chart time zones, sessions, the trading day and countdowns.

hourThe hour of the bar's opening time.minuteThe minute of the bar's opening time.weekdayThe day of the week of the bar's opening time.dayThe day of the month of the bar's opening time.monthThe month of the bar's opening time.yearThe year of the bar's opening time.session.withinTests whether the bar opens inside a time window of the day.session.elapsedHow many minutes have passed since a time window opened.session.startsTests whether this is the first bar inside a time window.period.startsTests whether this bar starts a new session, day, week, month, quarter or year.clock.nowThe chart clock: the time on the bar being run.clock.bar_closeThe time the bar being run closes.clock.to_closeHow long is left until the bar being run closes.clock.countdownThe time left in the bar being run, written as a countdown such as 3:05.clock.trading_dayThe trading day the bar belongs to, as a number such as 20261030.clock.chart_zoneThe name of the time zone the chart displays.clock.exchange_zoneThe name of the time zone of the exchange the symbol trades on.clock.formatWrites a time as text in a pattern you choose, such as 2026-10-30 09:30.clock.wallSplits a time into its year, month, day, hour, minute, second and weekday on a zone's clock.clock.timeBuilds a time from a date and a time of day on a zone's clock.clock.offsetHow many minutes a zone's clock is ahead of UTC at a given time.session.is_openTests whether the symbol's trading session is open on the chart clock.session.open_timeWhen the current trading session opened, or when the next one opens while it is closed.session.close_timeWhen the current trading session closes, or when the next one closes while it is closed.session.to_openHow long until the next trading session opens.session.to_closeHow long is left until the current trading session closes.

Symbol and timeframe

Facts about the chart's symbol and bar size. Fixed for a run, so they may be read in setup.

Math

Numbers. Every function returns missing when an input is missing, unless it says otherwise.

Text

Building and searching text.

Arrays

Ordered lists. Indexes start at 1.

Technical analysis

Averages, oscillators and signals. Each call keeps its own memory, so it must run on every bar (the call-site rule).

ta.true_rangeHow far price really moved on this bar, gaps from the previous close included.ta.smaThe simple moving average: the plain mean of the last length values.ta.emaThe exponential moving average, which follows recent prices more closely than a simple average.ta.rmaWilder's moving average, a slower exponential average used inside RSI and ATR.ta.wmaThe weighted moving average, where newer values count more.ta.vwmaThe volume-weighted moving average: bars with more volume count more.ta.linregThe value of the best straight line through the last length values, at the newest bar.ta.highestThe highest of the last length values, this bar included.ta.lowestThe lowest of the last length values, this bar included.ta.since_highestHow many bars ago the highest of the last length values was.ta.since_lowestHow many bars ago the lowest of the last length values was.ta.stdevHow spread out the last length values are (the standard deviation).ta.mean_devThe average distance of the last length values from their mean.ta.sumThe total of the last length values.ta.rocThe rate of change: how many percent x moved over length bars.ta.percent_rankWhere x stands against the previous length values, from 0 to 100.ta.rsiThe Relative Strength Index, a 0 to 100 measure of how strong recent gains are against recent losses.ta.swmaA short smoothing over the last four values, with the middle two counted twice.ta.cumsumA running total of every value since the first bar.ta.changeHow much x changed since length bars ago.ta.atrThe Average True Range: how far price typically moves per bar.ta.stochThe stochastic oscillator: where x sits inside the high to low range of the last length bars.ta.macdThe MACD: the gap between a fast and a slow EMA, with a signal line and a histogram.ta.bandsBands around a moving average, set a number of standard deviations above and below it.ta.crossoverTrue on the bar where a moves from at or below b to above it.ta.crossunderTrue on the bar where a moves from at or above b to below it.ta.crossTrue on the bar where a crosses b in either direction.ta.bars_sinceHow many bars ago a condition was last true.ta.value_whenThe value x had the last time a condition was true.ta.cciThe Commodity Channel Index: how far x is from its mean, in units of its mean deviation.ta.mfiThe Money Flow Index: a 0 to 100 measure of buying against selling pressure, weighted by volume.ta.almaThe Arnaud Legoux moving average: a Gaussian-weighted average that can lean towards the newest bars.ta.pivot_highA swing high: the value right bars ago when it is above the left values before it and the right values after it.ta.pivot_lowA swing low: the value right bars ago when it is below the left values before it and the right values after it.ta.fill_missingThe latest value of x that was not missing: gaps are filled with the value before them.ta.demaThe double exponential moving average, which lags less than ta.ema.ta.temaThe triple exponential moving average, which lags even less than ta.dema.ta.t3Tillson's T3: a very smooth average built from six exponential averages.ta.psarThe Parabolic SAR: a trailing stop that follows the trend and speeds up as it runs.ta.cummaxThe highest value x has had so far on the chart.ta.cumminThe lowest value x has had so far on the chart.ml.lorentzian_knnA nearest-neighbour vote: how the bars whose features looked most like this bar's were labelled.

Other timeframes and symbols

Reading a higher timeframe or another symbol, always through the chart's own data.

Using other indicators

Reading the outputs of another indicator, never its code: built-ins, Nexus library indicators, your own scripts, and indicators you have access to (NexuScript 1.5).

Colors

Named colours, custom colours, transparency and gradients.

Plotting and drawing

Plots, shading, lines, boxes, labels, markers, tables and the chart's own candles.

Order flow

Volume at each price inside a bar, and the order book.

Alerts and output

Telling the trader something happened.

Strategies

Order calls and reads, in strategy scripts only. An order call only records what the script asks for; backtests read it, nothing is sent.