Lipi Reference
Lipi

Functions

array.new()

Creates a new, empty-valued array of the given length. The element type is written in angle brackets, as in `array.new<float>(10)`. It takes a length only. To start every element at the same value, create the array first and then call `array.fill`, or use one of the typed constructors such as `array.new_float`, which accept an initial value.

Syntax

                array.new(series int length) → series array
              

Arguments

length series int

Return Type

series array

Example


          //@lipi=2
indicator("array.new Example", overlay=false)
// An array of 5 floats, then filled with 0.0
static array<float> values = array.new<float>(5)
array.fill(values, 0.0)
array.set(values, 0, close)
plot(array.get(values, 0), title="First Element", color=color.blue)