Reference
Arrays
Lists of values. Method style works too: prices.push(close).
array.abs(id)
A new array with absolute values.
Returns: the same type as the first argument
| Parameter | Type |
|---|---|
id | array |
array.avg(id)
Average of the items.
Returns: a number
| Parameter | Type |
|---|---|
id | array |
array.clear(id)
Removes every item.
Returns: nothing
| Parameter | Type |
|---|---|
id | array |
array.concat(id1, id2)
Appends the second array to the first.
Returns: the same type as the first argument
| Parameter | Type |
|---|---|
id1 | array |
id2 | array |
array.copy(id)
A copy of the array.
Returns: the same type as the first argument
| Parameter | Type |
|---|---|
id | array |
array.fill(id, value, index_from=0, index_to=na)
Sets items in a range to value.
Returns: nothing
| Parameter | Type | Notes |
|---|---|---|
id | array | |
value | any | |
index_from | int | Default 0 |
index_to | int | Default na |
array.first(id)
First item.
Returns: elem0
| Parameter | Type |
|---|---|
id | array |
array.from(...values)
A new array holding the given values.
Returns: fromarr
| Parameter | Type |
|---|---|
values | any |
array.get(id, index)
The item at index (-1 = last).
Returns: elem0
| Parameter | Type |
|---|---|
id | array |
index | int |
array.includes(id, value)
True if the value is in the array.
Returns: true or false
| Parameter | Type |
|---|---|
id | array |
value | any |
array.indexof(id, value)
First index of value (-1 if absent).
Returns: a whole number
| Parameter | Type |
|---|---|
id | array |
value | any |
array.insert(id, index, value)
Inserts an item at index.
Returns: nothing
| Parameter | Type |
|---|---|
id | array |
index | int |
value | any |
array.join(id, separator="")
The items joined as text.
Returns: text
| Parameter | Type | Notes |
|---|---|---|
id | array | |
separator | string | Default "" |
array.last(id)
Last item.
Returns: elem0
| Parameter | Type |
|---|---|
id | array |
array.lastindexof(id, value)
Last index of value (-1 if absent).
Returns: a whole number
| Parameter | Type |
|---|---|
id | array |
value | any |
array.max(id)
Largest item.
Returns: a number
| Parameter | Type |
|---|---|
id | array |
array.median(id)
Median of the items.
Returns: a number
| Parameter | Type |
|---|---|
id | array |
array.min(id)
Smallest item.
Returns: a number
| Parameter | Type |
|---|---|
id | array |
array.new(size=0, initial_value=na)
A new array (write the type: array.new<float>(...)).
Returns: newarr
| Parameter | Type | Notes |
|---|---|---|
size | int | Default 0 |
initial_value | any | Default na |
array.new_bool(size=0, initial_value=false)
A new array of bools.
Returns: an array of bool
| Parameter | Type | Notes |
|---|---|---|
size | int | Default 0 |
initial_value | bool | Default false |
array.new_box(size=0, initial_value=na)
A new array of boxes.
Returns: an array of box
| Parameter | Type | Notes |
|---|---|---|
size | int | Default 0 |
initial_value | box | Default na |
array.new_color(size=0, initial_value=na)
A new array of colors.
Returns: an array of color
| Parameter | Type | Notes |
|---|---|---|
size | int | Default 0 |
initial_value | color | Default na |
array.new_float(size=0, initial_value=na)
A new array of floats.
Returns: an array of float
| Parameter | Type | Notes |
|---|---|---|
size | int | Default 0 |
initial_value | float | Default na |
array.new_int(size=0, initial_value=na)
A new array of ints.
Returns: an array of int
| Parameter | Type | Notes |
|---|---|---|
size | int | Default 0 |
initial_value | int | Default na |
array.new_label(size=0, initial_value=na)
A new array of labels.
Returns: an array of label
| Parameter | Type | Notes |
|---|---|---|
size | int | Default 0 |
initial_value | label | Default na |
array.new_line(size=0, initial_value=na)
A new array of lines.
Returns: an array of line
| Parameter | Type | Notes |
|---|---|---|
size | int | Default 0 |
initial_value | line | Default na |
array.new_string(size=0, initial_value=na)
A new array of strings.
Returns: an array of string
| Parameter | Type | Notes |
|---|---|---|
size | int | Default 0 |
initial_value | string | Default na |
array.pop(id)
Removes and returns the last item.
Returns: elem0
| Parameter | Type |
|---|---|
id | array |
array.push(id, value)
Adds an item at the end.
Returns: nothing
| Parameter | Type |
|---|---|
id | array |
value | any |
array.range(id)
Largest minus smallest item.
Returns: a number
| Parameter | Type |
|---|---|
id | array |
array.remove(id, index)
Removes and returns the item at index.
Returns: elem0
| Parameter | Type |
|---|---|
id | array |
index | int |
array.reverse(id)
Reverses the order in place.
Returns: nothing
| Parameter | Type |
|---|---|
id | array |
array.set(id, index, value)
Replaces the item at index.
Returns: nothing
| Parameter | Type |
|---|---|
id | array |
index | int |
value | any |
array.shift(id)
Removes and returns the first item.
Returns: elem0
| Parameter | Type |
|---|---|
id | array |
array.size(id)
Number of items.
Returns: a whole number
| Parameter | Type |
|---|---|
id | array |
array.slice(id, index_from, index_to=na)
A copy of part of the array.
Returns: the same type as the first argument
| Parameter | Type | Notes |
|---|---|---|
id | array | |
index_from | int | |
index_to | int | Default na |
array.sort(id, order="ascending")
Sorts in place (order.ascending or order.descending).
Returns: nothing
| Parameter | Type | Notes |
|---|---|---|
id | array | |
order | string | Default "ascending" |
array.sort_indices(id, order="ascending")
Indices that would sort the array.
Returns: an array of int
| Parameter | Type | Notes |
|---|---|---|
id | array | |
order | string | Default "ascending" |
array.stdev(id, biased=true)
Standard deviation of the items.
Returns: a number
| Parameter | Type | Notes |
|---|---|---|
id | array | |
biased | bool | Default true |
array.sum(id)
Sum of the items.
Returns: a number
| Parameter | Type |
|---|---|
id | array |
array.unshift(id, value)
Adds an item at the start.
Returns: nothing
| Parameter | Type |
|---|---|
id | array |
value | any |
array.variance(id, biased=true)
Variance of the items.
Returns: a number
| Parameter | Type | Notes |
|---|---|---|
id | array | |
biased | bool | Default true |
Education only. Not financial advice. Examples are teaching samples, not trading results.
