Functions
array.new_box()
Creates an array of `box` IDs with `size` elements, each set to `initial_value`. Arrays of drawing IDs are the usual way to keep a limited history of drawings: push each new box and delete the oldest when the array grows past a limit. Both arguments are optional; elements start as `na` when `initial_value` is left out.
Syntax
array.new_box(series int size, series box initial_value) → series array<box>
Arguments
size series int initial_value series box Return Type
series array<box> Example
//@lipi=2
indicator("array.new_box Example", overlay=true)
// Keep only the 3 most recent inside-bar boxes
static array<box> boxes = array.new_box(0)
if high < high[1] and low > low[1] {
array.push(boxes, box.new(bar_index[1], high[1], bar_index, low[1], bgcolor=color.new(color.orange, 0.2)))
if array.length(boxes) > 3 {
box.delete(array.shift(boxes))
}
}