Combines the items of an array into one string, with a separator between them.
Each item is turned into text the way str.tostring() does it, so floats show their decimals and na reads as NaN. The default separator is a comma with no space.
It is the quickest way to print an array in a label, tooltip, table cell or alert message.
Syntax
array.join(id: array<int/float/string>, separator: series string (optional)) -> series string
array.join(separator: series string (optional)) -> series stringArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | array<int/ | required | The array whose items are written into one string, in order, with the separator between them. |
| separator | series string | ", | Text placed between items. |
Returns
series string: A string of all items separated by the separator.
Remarks
- Only arrays of numbers and strings are accepted; convert other types to text first.
Example
//@version=6
indicator("array.join: window label", overlay = true)
var win = array.new<string>()
array.push(win, str.tostring(close, "#.##"))
if array.size(win) > 4
array.shift(win)
if barstate.islast
label.new(bar_index, high, array.join(win, " | "))See also
Runs on Sidechair