Library "Table"
This library provides an easy way to convert arrays and matrixes of data into tables. There are a few different implementations of each function so you can get more or less control over the appearance of the tables. The basic rule of thumb is that all matrix rows must have the same number of columns, and if you are providing multiple arrays/matrixes to specify additional colors (background/text), they must have the same number of rows/columns as the data array. Finally, you do have the option of spanning cells across rows or columns with some special syntax in the data cell. Look at the examples to see how the arrays and matrixes need to be built before they can be used by the functions.

floatArrayToCellArray(floatArray)
  Helper function that converts a float array to a Cell array so it can be rendered with the fromArray function
  Parameters:
    floatArray (float): (array<float>) the float array to convert to a Cell array.
  Returns: array<Cell> The Cell array to return.

stringArrayToCellArray(stringArray)
  Helper function that converts a string array to a Cell array so it can be rendered with the fromArray function
  Parameters:
    stringArray (string): (array<string>) the array to convert to a Cell array.
  Returns: array<Cell> The Cell array to return.

floatMatrixToCellMatrix(floatMatrix)
  Helper function that converts a float matrix to a Cell matrix so it can be rendered with the fromMatrix function
  Parameters:
    floatMatrix (matrix<float>): (matrix<float>) the float matrix to convert to a string matrix.
  Returns: matrix<Cell> The Cell matrix to render.

stringMatrixToCellMatrix(stringMatrix)
  Helper function that converts a string matrix to a Cell matrix so it can be rendered with the fromMatrix function
  Parameters:
    stringMatrix (matrix<string>): (matrix<string>) the string matrix to convert to a Cell matrix.
  Returns: matrix<Cell> The Cell matrix to return.

fromMatrix(CellMatrix, position, verticalOffset, transposeTable, textSize, borderWidth, tableNumRows, blankCellText)
  Takes a CellMatrix and renders it as a table.
  Parameters:
    CellMatrix (matrix<Cell>): (matrix<Cell>) The Cells to be rendered in a table
    position (string): (string) Optional. The position of the table. Defaults to position.top_right
    verticalOffset (int): (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
    transposeTable (bool): (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
    textSize (string): (string) Optional. The size of text to render in the table. Defaults to size.small.
    borderWidth (int): (int) Optional. The width of the border between table cells. Defaults to 2.
    tableNumRows (int): (int) Optional. The number of rows in the table. Not required, defaults to the number of rows in the provided matrix. If your matrix will have a variable number of rows, you must provide the max number of rows or the function will error when it attempts to set a cell value on a row that the table hadn't accounted for when it was defined.
    blankCellText (string): (string) Optional. Text to use cells when adding blank rows for vertical offsetting.

fromMatrix(dataMatrix, position, verticalOffset, transposeTable, textSize, borderWidth, tableNumRows, blankCellText)
  Renders a float matrix as a table.
  Parameters:
    dataMatrix (matrix<float>): (matrix_float) The data to be rendered in a table
    position (string): (string) Optional. The position of the table. Defaults to position.top_right
    verticalOffset (int): (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
    transposeTable (bool): (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
    textSize (string): (string) Optional. The size of text to render in the table. Defaults to size.small.
    borderWidth (int): (int) Optional. The width of the border between table cells. Defaults to 2.
    tableNumRows (int): (int) Optional. The number of rows in the table. Not required, defaults to the number of rows in the provided matrix. If your matrix will have a variable number of rows, you must provide the max number of rows or the function will error when it attempts to set a cell value on a row that the table hadn't accounted for when it was defined.
    blankCellText (string): (string) Optional. Text to use cells when adding blank rows for vertical offsetting.

fromMatrix(dataMatrix, position, verticalOffset, transposeTable, textSize, borderWidth, tableNumRows, blankCellText)
  Renders a string matrix as a table.
  Parameters:
    dataMatrix (matrix<string>): (matrix_string) The data to be rendered in a table
    position (string): (string) Optional. The position of the table. Defaults to position.top_right
    verticalOffset (int): (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
    transposeTable (bool): (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
    textSize (string): (string) Optional. The size of text to render in the table. Defaults to size.small.
    borderWidth (int): (int) Optional. The width of the border between table cells. Defaults to 2.
    tableNumRows (int): (int) Optional. The number of rows in the table. Not required, defaults to the number of rows in the provided matrix. If your matrix will have a variable number of rows, you must provide the max number of rows or the function will error when it attempts to set a cell value on a row that the table hadn't accounted for when it was defined.
    blankCellText (string): (string) Optional. Text to use cells when adding blank rows for vertical offsetting.

fromArray(dataArray, position, verticalOffset, transposeTable, textSize, borderWidth, blankCellText)
  Renders a Cell array as a table.
  Parameters:
    dataArray (Cell): (array<Cell>) The data to be rendered in a table
    position (string): (string) Optional. The position of the table. Defaults to position.top_right
    verticalOffset (int): (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
    transposeTable (bool): (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
    textSize (string): (string) Optional. The size of text to render in the table. Defaults to size.small.
    borderWidth (int): (int) Optional. The width of the border between table cells. Defaults to 2.
    blankCellText (string): (string) Optional. Text to use cells when adding blank rows for vertical offsetting.

fromArray(dataArray, position, verticalOffset, transposeTable, textSize, borderWidth, blankCellText)
  Renders a string array as a table.
  Parameters:
    dataArray (string): (array_string) The data to be rendered in a table
    position (string): (string) Optional. The position of the table. Defaults to position.top_right
    verticalOffset (int): (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
    transposeTable (bool): (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
    textSize (string): (string) Optional. The size of text to render in the table. Defaults to size.small.
    borderWidth (int): (int) Optional. The width of the border between table cells. Defaults to 2.
    blankCellText (string): (string) Optional. Text to use cells when adding blank rows for vertical offsetting.

fromArray(dataArray, position, verticalOffset, transposeTable, textSize, borderWidth, blankCellText)
  Renders a float array as a table.
  Parameters:
    dataArray (float): (array_float) The data to be rendered in a table
    position (string): (string) Optional. The position of the table. Defaults to position.top_right
    verticalOffset (int): (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
    transposeTable (bool): (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
    textSize (string): (string) Optional. The size of text to render in the table. Defaults to size.small.
    borderWidth (int): (int) Optional. The width of the border between table cells. Defaults to 2.
    blankCellText (string): (string) Optional. Text to use cells when adding blank rows for vertical offsetting.

debug(message, position)
  Renders a debug message in a table at the desired location on screen.
  Parameters:
    message (string): (string) The message to render.
    position (string): (string) Optional. The position of the debug message. Defaults to position.middle_right.

Cell
  Type for each cell's content and appearance
  Fields:
    content (series string)
    bgColor (series color)
    textColor (series color)
    align (series string)
    colspan (series int)
    rowspan (series int)

I release TradingView indicators and libraries designed to make you a better trader. For detailed info about them, head over to improve.trading
Pine脚本库

本着真正的TradingView精神,作者将此Pine代码以开源脚本库发布,以便我们社区的其他Pine程序员可以重用它。向作者致敬!您可以私下或在其他开源出版物中使用此库,但在出版物中重用此代码受网站规则约束。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想使用这个脚本库吗?

复制以下行并将其粘贴到您的脚本中。