New array types and functions

Dec 4, 2020

We’re glad to announce that we’ve added support for strings, labels, and lines to arrays.

Now you can create arrays of these types using the array.new.*() construction:

array.new_line(size, initial_value)
array.new_label(size, initial_value)
array.new_string(size, initial_value)

For example, if you want to create an array of strings, it’ll look like this:

a=array.new_string(5, "example")

where 5 is the size of the array (optional) and “example” is the initial value (optional).

Also, we’ve added several new functions for working with arrays.

The array.join(id, separator) function unites all the elements of an array into one string by inserting the specified separator between the elements. separator is an optional string parameter, empty string by default. The id parameter takes int[], float[], string[]. Returns a string.

The str.split(string, separator) function splits a string into an array of strings based on the specified substring separator. Takes two strings, returns a string[] array.

The array.range(id) function returns the statistical range of an array, i.e. the maximum array element minus the minimum array element. Only int and float arrays are supported.

Look first Then leap

TradingView is built for you, so make sure you're getting the most of our awesome features
Launch Chart