Lipi Reference
Lipi

Functions

array.new_color()

Creates an array of `color` elements with `size` elements, each set to `initial_value`. Both arguments are optional: leave `size` out for an empty array, and `initial_value` out for elements that start as `na`.

Syntax

                array.new_color(series int size, series color initial_value) → series array<color>
              

Arguments

size series int
initial_value series color

Return Type

series array<color>

Example


          //@lipi=2
indicator("array.new_color Example", overlay=true)
palette = array.new_color(0)
array.push(palette, color.red)
array.push(palette, color.green)
array.push(palette, color.blue)
// Cycle through the palette bar by bar
barcolor(array.get(palette, bar_index % array.length(palette)))