Functions
array.new_line()
Creates an array of `line` 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 line 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_line(series int size, series line initial_value) → series array<line>
Arguments
size series int initial_value series line Return Type
series array<line> Example
//@lipi=2
indicator("array.new_line Example", overlay=true)
// Keep only the 3 most recent horizontal lines at each new 20-bar high
static array<line> lines = array.new_line(0)
if high == talib.highest(high, 20) {
array.push(lines, line.new(bar_index, high, bar_index + 10, high, color=color.green))
if array.length(lines) > 3 {
line.delete(array.shift(lines))
}
}