//@version=5
indicator('Calculations on arrays')
t = table.new(position.bottom_right, 7, 20, border_width = 2)
// Index
table.cell(table_id = t, column = 0, row = 0, text = "Index", bgcolor = #999999)
for i = 0 to 5
table.cell(table_id = t, column = i + 1, row = 0, text = str.tostring(i), bgcolor = #999999)
// First array
arr1 = array.from(5, 3, 0, 2, 3, 1)
table.cell(table_id = t, column = 0, row = 1, text = "arr1 = array.from(5, 3, 0, 2, 3, 1)", bgcolor = #999999)
for i = 0 to array.size(arr1) - 1
table.cell(table_id = t, column = i + 1, row = 1, text = str.tostring(array.get(arr1, i)), bgcolor = #cccccc)
// Second array
arr2 = array.from(1, 5, 4, 6, 0, 2)
table.cell(table_id = t, column = 0, row = 2, text = "arr2 = array.from(1, 5, 4, 6, 0, 2)", bgcolor = #999999)
for i = 0 to array.size(arr2) - 1
table.cell(table_id = t, column = i + 1, row = 2, text = str.tostring(array.get(arr2, i)), bgcolor = #cccccc)
// Avg
table.cell(table_id = t, column = 0, row = 3, text = "array.avg(arr1)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 3, text = str.tostring(array.avg(arr1)), bgcolor = #cccccc)
// max
table.cell(table_id = t, column = 0, row = 4, text = "array.max(arr1)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 4, text = str.tostring(array.max(arr1)), bgcolor = #cccccc)
// median
table.cell(table_id = t, column = 0, row = 5, text = "array.median(arr1)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 5, text = str.tostring(array.median(arr1)), bgcolor = #cccccc)
// min
table.cell(table_id = t, column = 0, row = 6, text = "array.min(arr1)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 6, text = str.tostring(array.min(arr1)), bgcolor = #cccccc)
// mode
table.cell(table_id = t, column = 0, row = 7, text = "array.mode(arr1)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 7, text = str.tostring(array.mode(arr1)), bgcolor = #cccccc)
// range
table.cell(table_id = t, column = 0, row = 8, text = "array.range(arr1)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 8, text = str.tostring(array.range(arr1)), bgcolor = #cccccc)
// stdev
table.cell(table_id = t, column = 0, row = 9, text = "array.stdev(arr1)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 9, text = str.tostring(array.stdev(arr1)), bgcolor = #cccccc)
// variance
table.cell(table_id = t, column = 0, row = 10, text = "array.variance(arr1)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 10, text = str.tostring(array.variance(arr1)), bgcolor = #cccccc)
// sum
table.cell(table_id = t, column = 0, row = 11, text = "array.sum(arr1)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 11, text = str.tostring(array.sum(arr1)), bgcolor = #cccccc)
// covariance
table.cell(table_id = t, column = 0, row = 12, text = "array.covariance(arr1, arr2)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 12, text = str.tostring(array.covariance(arr1, arr2)), bgcolor = #cccccc)
// includes
table.cell(table_id = t, column = 0, row = 13, text = "array.includes(arr1, 1)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 13, text = str.tostring(array.includes(arr1, 1)), bgcolor = #cccccc)
// includes
table.cell(table_id = t, column = 0, row = 14, text = "array.includes(arr1, 7)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 14, text = str.tostring(array.includes(arr1, 7)), bgcolor = #cccccc)
// index of
table.cell(table_id = t, column = 0, row = 15, text = "array.indexof(arr1, 3)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 15, text = str.tostring(array.indexof(arr1, 3)), bgcolor = #cccccc)
// index of
table.cell(table_id = t, column = 0, row = 16, text = "array.indexof(arr1, 7)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 16, text = str.tostring(array.indexof(arr1, 7)), bgcolor = #cccccc)
// last index of
table.cell(table_id = t, column = 0, row = 17, text = "array.lastindexof(arr1, 3)", bgcolor = #999999)
table.cell(table_id = t, column = 1, row = 17, text = str.tostring(array.lastindexof(arr1, 3)), bgcolor = #cccccc)
Информация по комментариям в разработке