Inserts an array as a new row of a matrix, at the end unless you give a position.
The array supplies the new row's items and must have as many items as the matrix has columns. Rows from the chosen position downward move one place. Pass row = matrix.rows(m) or leave it out to append.
On an empty matrix the array's length sets the number of columns, which is how a matrix is grown from nothing, one observation per row.
Syntax
matrix.add_row(id: any matrix type, row: series int (optional), array_id: any array type) -> void
matrix.add_row(row: series int (optional), array_id: any array type) -> voidArguments
| Name | Type | Default | Description |
|---|---|---|---|
| id | any matrix type | required | The matrix that receives the new row. Its row count grows by one. |
| row | series int | the end of the matrix | Index of the row. Counts from 0. |
| array_id | any array type | required | The array whose items become the new row or column. |
Returns
Nothing.
Example
//@version=6
indicator("matrix.add_row: history", overlay = false)
var matrix<float> hist = matrix.new<float>()
matrix.add_row(hist, matrix.rows(hist), array.from(open, close))
plot(matrix.rows(hist), "Rows stored")See also
Runs on Sidechair