Lipi Reference
Lipi

Functions

array.shift()

Removes the first element of the array and returns it. The remaining elements move down one index. Paired with `array.push`, it keeps a fixed-length window of recent values.

Syntax

                array.shift(series array id) → series 
              

Arguments

id required series array

Return Type

series

Example


          //@lipi=2
indicator("array.shift Example", overlay=true)
// A rolling window of the last 5 closes
static array<float> window = array.new_float(5, close)
array.shift(window)
array.push(window, close)
plot(array.avg(window), title="5-Bar Average", color=color.blue)