Built-in Types

series

Series is a list of values that stretches back in time from the current bar. Indexing the series returns the new series shifted by the specified amount of bars backward. For example:

Index

0

1

2

3

4

5

6

7

8

9

close

15.25

15.46

15.35

15.03

15.02

14.80

15.01

12.87

12.53

12.43

close[1]

nil

15.25

15.46

15.35

15.03

15.02

14.80

15.01

12.87

12.53

close[2]

nil

nil

15.25

15.46

15.35

15.03

15.02

14.80

15.01

12.87

close[3]

nil

nil

nil

15.25

15.46

15.35

15.03

15.02

14.80

15.01

Series support the number of arithmetic and comparison operations. For example, (open+close)/2 will return the series, which values are the half sum of the open and close.

Operator

Left-hand side

Right-hand side

Result

+,-,*,/,^

series or numeric

series or numeric

series

<,>,<=,>=

series or numeric

series or numeric

boolean

==, ~=

series

series

boolean

-

series

series

Where:

  • ^ - power operator.

  • ~= - inequality operator.

Due to Lua limitations, it is not possible to compare series and a value directly. In this case, get_value should be used.

For example:

if get_value(open) > 10 then
    print ("Hooray!")
end

The same restriction applies when using the series as a condition.

series[numeric]

A series that consists of numeric values.

series[integer]

A series that consists of integer values.

series[boolean]

A series that consists of boolean values.

integer

A 64-bit signed integer value.

numeric

A 64-bit floating point value.

boolean

A boolean value with the values true and false. By default, in Lua the condition is considered to be false when its value is false or nil. In some cases, that are explicitly documented, we also consider 0 to be false.

string

A string value.

color

A string, that represents the color in the following formats:

  • "#RRGGBB"

  • "#RRGGBB"

  • "#RRGGBBAA"

  • "rgb(255,255,255)"

  • "rgb(255,255,255,1.0)"

  • HTML color name

For convenience, there are two functions available to create the color: rgb and rgba.