Sidechair

array.concat()

Browse the reference

Appends all items of a second array to the end of the first and returns the first array.

Try it in the editor

After array.concat(a, b) the array a holds its own items followed by those of b, while b is unchanged. The returned value is a itself, not a new array, so the result can be assigned or ignored.

The two arrays have to hold the same item type, and the combined length may not pass 100,000 items.

Syntax

Pine Script
array.concat(id1: any array type, id2: any array type) -> array<type>
array.concat(id2: any array type) -> array<type>

Arguments

NameTypeDefaultDescription
id1any array typerequiredThe array that is read, or that receives the result.
id2any array typerequiredThe array whose items are appended to the first array. It is left as it is.

Returns

array<type>: The first array, now including the items of the second.

Remarks

  • To merge into a fresh array and keep both sources untouched, call array.copy() on the first one and concatenate onto the copy.

Example

Pine ScriptJoin two level listsOpen in editor
//@version=6
indicator("array.concat: all levels", overlay = true)
supports = array.from(low, low[1])
resistances = array.from(high, high[1])
all = array.concat(array.copy(supports), resistances)
plot(array.min(all), "Lowest", color.red)
plot(array.max(all), "Highest", color.green)

See also

Runs on Sidechair