Deletes a row from a matrix and returns it as an array.
The rows below move up. Without a row index the last row is removed. A row index outside the matrix stops the script with an error.
The removed items come back as an array, so a queue of observations can drop its oldest row with matrix.remove_row(m, 0).
Syntax
matrix.remove_row(id: any matrix type, row: series int (optional)) -> array<>
matrix.remove_row(row: series int (optional)) -> array<>Arguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any matrix type | required | The matrix to take a row out of. Its row count drops by one. |
| row | series int | the last row | Index of the row. Counts from 0. |
Returns
array<>: An array holding the removed row.
Example
//@version=6
indicator("matrix.remove_row: rolling rows", overlay = false)
var matrix<float> hist = matrix.new<float>()
matrix.add_row(hist, matrix.rows(hist), array.from(close, volume))
if matrix.rows(hist) > 10
matrix.remove_row(hist, 0)
plot(matrix.rows(hist), "Rows kept")See also
Runs on Sidechair