Skip to content

Operator

Like as many programming languages, Navi Stream supports basic arithmetic and logical operators.

Navi Stream also follows the precedence of traditional programming languages, so you can continue to use it in Navi Stream syntax according to your previous programming habits.

nvs
let a = 100 + 2 - 10 * 5 / 2 % 3;
// 101

Operators

OperatorDescription
!aBitwise or logical complement
a + bArithmetic addition
a += bArithmetic addition and assignment
-aArithmetic negation
a - bArithmetic subtraction
a -= bArithmetic subtraction and assignment
a * bArithmetic multiplication
a *= bArithmetic multiplication and assignment
a / bArithmetic division
a /= bArithmetic division and assignment
a % bArithmetic remainder
a %= bArithmetic remainder and assignment
a < bLess than comparison
a <= bLess than or equal to comparison
a = 1Assignment/equivalence
a == bEquality comparison
a > bGreater than comparison
a >= bGreater than or equal to comparison
a != nNonequality comparison
a && bAND logical
a || bOR logical
expr.identMember access
a[n]Ref preview n period data

Ref preview data

We can use quote.close[n] to reference the data of the previous.

For example, we have data of K line (1m):

idxtimeclose
110:0010.25
210:0110.50
310:0210.75
410:0311.00
510:0411.25

If now we at the period of idx 5:

  • quote.close[0] is the current data.
  • quote.close[1] is the data of the previous 1 period, value is 11.00.
  • quote.close[2] is the data of the previous 2 period, value is 10.75.
  • quote.close[3] is the data of the previous 3 period, value is 10.50.