Sector/Industry
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SelfUnmade

//@version=5
indicator("Sector/Industry", overlay = true)
sector = syminfo.sector
industry = syminfo.industry

group_pos = 'Table Position'
string i_tableYpos = input.string('top', 'X', inline='01', group=group_pos, options=['top', 'middle', 'bottom'])
string i_tableXpos = input.string('right', 'Y', inline='01', group=group_pos, options=['left', 'center', 'right'], tooltip='Position on the chart.')

string i_textSize = input.string('Small', 'Panel Text Size', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], inline = '02', group=group_pos)
string textSize = i_textSize == 'Auto' ? size.auto : i_textSize == 'Tiny' ? size.tiny : i_textSize == 'Small' ? size.small : i_textSize == 'Normal' ? size.normal : i_textSize == 'Large' ? size.large : size.huge

string tablelayout = input.string('Vertical', 'Table Layout', options=['Vertical', 'Horizontal'], inline = '03', group=group_pos)
int l = tablelayout == 'Vertical' ? 1 : 2

bgColor = input.color(color.new(color.black, 0), "BG Color ", inline= '04', group=group_pos)
textColor = input.color(color.new(color.white,0), " Text Color ", inline = '04', group=group_pos)

var table= table.new(i_tableYpos + '_' + i_tableXpos, columns =2, rows=2, border_width=1 )

if l == 1
    table.cell(table, 0, 0, industry, text_color = textColor, bgcolor = bgColor, text_size= textSize, width=0, height=0)
    table.cell(table, 0, 1, sector, text_color = textColor, bgcolor = bgColor, text_size= textSize, width=0, height=0)

if l == 2
    table.cell(table, 0, 0, industry, text_color = textColor, bgcolor = bgColor, text_size= textSize, width=0, height=0)
    table.cell(table, 1, 0, sector, text_color = textColor, bgcolor = bgColor, text_size= textSize, width=0, height=0)
