ta or color, or a named part of a tuple.Adds two numbers.
Syntax
a + bDetails
Also unary: +x is x.
Missing values
If either side is missing, the result is missing.
Example
plot("High plus low", high + low)See also
Subtracts, or flips the sign of a number.
Syntax
a - b
-aDetails
-2^2 is -4: the power binds tighter.
Missing values
If either side is missing, the result is missing.
Example
plot("Bar change", close - open)See also
Multiplies two numbers, or joins two texts.
Syntax
a * b
text * textDetails
Text joins only with text: "Close " * string(close).
Missing values
A missing number gives missing.
Example
plot("Double range", (high - low) * 2)See also
Divides two numbers.
Syntax
a / bDetails
Missing values
A missing side gives missing.
Example
plot("Close to open", close / open)See also
The remainder of a division, with the sign of the left side.
Syntax
a % bDetails
-7 % 3 is -1. Use mod for the remainder that follows the divisor's sign.
Missing values
A missing side gives missing.
Example
plot("Bar in group of 5", bar.index % 5)See also
Raises a number to a power.
Syntax
a ^ bDetails
Binds from the right: 2^3^2 is 2^9. Computed by NexuScript itself, so it gives the same last digit everywhere.
Missing values
A missing side gives missing.
Example
plot("Squared change", (close - close[1]) ^ 2)See also
True when two values of the same type are equal.
Syntax
a == bDetails
Colours compare by their channels, enums by member. Comparisons chain: 0 < x <= 10 means 0 < x && x <= 10.
Missing values
Any comparison with missing is false. Writing x == missing is an error: use ismissing(x).
Example
if bar.index == 0
marker("First")
endSee also
True when two values of the same type differ.
Syntax
a != bDetails
The opposite of ==.
Missing values
With missing on either side the result is true.
Example
if close != open
background(color.fade(color.blue, 95))
endSee also
True when the left number is smaller.
Syntax
a < bDetails
Chains with other comparisons: low < x < high.
Missing values
False when either side is missing.
Example
if close < open
candle_color(color.red)
endSee also
True when the left number is smaller or equal.
Syntax
a <= bDetails
Chains with other comparisons.
Missing values
False when either side is missing.
Example
if close <= low[1]
marker("Low", position = "below")
endSee also
True when the left number is larger.
Syntax
a > bDetails
Chains with other comparisons.
Missing values
False when either side is missing.
Example
if close > open
candle_color(color.green)
endSee also
True when the left number is larger or equal.
Syntax
a >= bDetails
Chains with other comparisons.
Missing values
False when either side is missing.
Example
if close >= high[1]
marker("High")
endSee also
True when both sides are true.
Syntax
a && bDetails
The right side is only worked out when the left is true. A ta call on the right side is allowed only when the left side is fixed.
Missing values
Both sides are Bool, which is never missing.
Example
if close > open && volume > volume[1]
marker("Strong")
endSee also
True when either side is true.
Syntax
a || bDetails
The right side is only worked out when the left is false.
Missing values
Both sides are Bool, which is never missing.
Example
if high > high[1] || low < low[1]
marker("Wide")
endSee also
Turns true into false and false into true.
Syntax
!aDetails
Works on Bool only.
Missing values
Bool is never missing.
Example
if !bar.confirmed
background(color.fade(color.yellow, 90))
endSee also
Picks one of two values by a condition.
Syntax
condition ? a : bDetails
a and b must have the same type. Binds loosest of all and groups from the right, so a ? b : c ? d : e reads naturally.
Missing values
Only the chosen side is worked out; a missing value is passed through.
Example
plot("Close", close, color = close >= open ? color.green : color.red)See also
Reads a value from n bars ago, or an item of an array.
Syntax
series[n]
array[i]Details
Missing values
Before the first bar a history read gives missing (false for Bool, color.none for colours).
Example
let change = close - close[1]
let fast = ta.ema(close, 9)
plot("Change", change)
plot("Fast was rising", fast[1] > fast[2] ? 1 : 0)See also
Puts values inside text.
Syntax
"text $name text $(expression)"Details
$name and $(expression) are replaced by string(value). Numbers are written in their shortest exact form; write \$ for a dollar sign.
Missing values
A missing number is written missing.
Example
marker("Close $(round(close, digits = 2))")See also
Reads a name from a namespace such as ta or color, or a named part of a tuple.
Syntax
namespace.name
tuple.partDetails
Namespaces: ta, color, symbol, timeframe, session, period, bar, and in strategies order, position, account.
Missing values
A part of a tuple may be missing like any number.
Example
let (basis, upper, lower) = ta.bands(close, 20)
let daily = higher("D") do
(high = high, low = low)
end
plot("Yesterday high", daily.high)