Builds an array of text items, with na as the default so blank slots need an explicit empty string.
array.new_string(3, "-") holds three dashes. The default item is na, not an empty string, so pass "" as initial_value when blank slots are what you want.
Fixed-size string arrays suit table captions, per-rule status words and weekday names. array.join() turns the whole array into one string with a separator you choose, and str.split() goes the other way.
Syntax
array.new_string(size: series int (optional), initial_value: series string (optional)) -> array<string>Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| size | series int | 0 | How many text slots to start with: 0 or more, up to 100,000. A fixed size works well for captions that are overwritten with array.set(). |
| initial_value | series string | na | The string written into every slot. Pass an empty string for blanks, since leaving it out gives na and not "". |
Returns
array<string>: A new array of strings with the requested size, every slot holding initial_value or na.
Example
//@version=6
indicator("array.new_string: status line", overlay = true)
var parts = array.new_string(3, "")
array.set(parts, 0, close > open ? "up" : "down")
array.set(parts, 1, ta.rsi(close, 14) > 70 ? "hot" : ta.rsi(close, 14) < 30 ? "cold" : "mid")
array.set(parts, 2, volume > ta.sma(volume, 20) ? "busy" : "quiet")
if barstate.islast
label.new(bar_index, high, array.join(parts, " / "))
plot(close, "Close")See also
Runs on Sidechair