0

The Dashboard

This what i have accomplished so far:

var dashboard = table.new(position = position.top_right, columns = 3, rows = 5, border_width = 5, frame_color = color.new(color.white, 100))

table.cell(dashboard, 0, 0, text = "Trend", text_color = color.white, text_halign = text.align_left, text_valign = text.align_center, bgcolor = color.gray)
table.cell(dashboard, 1, 0, text = "Uptrend", text_color = color.white, text_halign = text.align_center, text_valign = text.align_center, bgcolor = color.lime, width = 5)
table.cell(dashboard, 2, 0, text = "Downtrend", text_color = color.white, text_halign = text.align_center, text_valign = text.align_center, bgcolor = color.red, width = 5)

table.cell(dashboard, 0, 1, text = "Stocks", text_color = color.white, text_halign = text.align_left, text_valign = text.align_center, bgcolor = color.gray)
table.cell(dashboard, 1, 1, text = str.tostring(uptrend), text_color = color.white, text_halign = text.align_center, text_valign = text.align_center, bgcolor = color.lime, width = 5)
table.cell(dashboard, 2, 1, text = str.tostring(downtrend), text_color = color.white, text_halign = text.align_center, text_valign = text.align_center, bgcolor = color.red, width = 5)

table.cell(dashboard, 0, 2, text = "Stocks (%)", text_color = color.white, text_halign = text.align_left, text_valign = text.align_center, bgcolor = color.gray)
table.cell(dashboard, 1, 2, text = str.tostring(uptrendPercentage), text_color = color.white, text_halign = text.align_center, text_valign = text.align_center, bgcolor = color.lime, width = 5)
table.cell(dashboard, 2, 2, text = str.tostring(downtrendPercentage), text_color = color.white, text_halign = text.align_center, text_valign = text.align_center, bgcolor = color.red, width = 5)

table.cell(dashboard, 0, 3, text = "Weight (%)", text_color = color.white, text_halign = text.align_left, text_valign = text.align_center, bgcolor = color.gray)
table.cell(dashboard, 1, 3, text = str.tostring(uptrendWeight), text_color = color.white, text_halign = text.align_center, text_valign = text.align_center, bgcolor = color.lime, width = 5)
table.cell(dashboard, 2, 3, text = str.tostring(downtrendWeight), text_color = color.white, text_halign = text.align_center, text_valign = text.align_center, bgcolor = color.red, width = 5)

table.cell(dashboard, 0, 4, text = "Dollar", text_color = color.white, text_halign = text.align_left, text_valign = text.align_center, bgcolor = color.gray)
table.cell(dashboard, 1, 4, text = Dtrend, text_color = color.white, text_halign = text.align_center, text_valign = text.align_center, bgcolor = Dcolor, width = 5)

How can i make the last table cell span across two columns?

‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎ ‎

saleem
  • 41
  • 4

1 Answers1

2

You should use the table.merge_cells() function.

Here is an example:

//@version=5
indicator("My script")

var testTable = table.new(position = position.top_right, columns = 3, rows = 3, bgcolor = color.yellow, border_width=2, border_color=color.black)

if barstate.islast
    table.cell(testTable, 0, 0, "Trend")
    table.cell(testTable, 1, 0, "Uptrend")
    table.cell(testTable, 2, 0, "Downtrend")

    table.cell(testTable, 0, 1, "Trend value")
    table.cell(testTable, 1, 1, "Uptrend value")
    table.cell(testTable, 2, 1, "Downtrend value")

    table.cell(testTable, 0, 2, "Random text")
    table.cell(testTable, 1, 2, "Merged text")
    table.merge_cells(testTable, 1, 2, 2, 2)

enter image description here

vitruvius
  • 15,740
  • 3
  • 16
  • 26