[HELPER] Symbol Info Array Table Helper
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RozaniGhani-RG

//@version=5
indicator('[HELPER] Symbol Info Array Table Helper', shorttitle = 'HSIATH', overlay = true)

// 0. Tooltips
// 1. Inputs for table
// 2. Inputs for array
// 3. New array
// 4. Custom functions
// 5. array values push / set
// 6. Construct

// ————————————————————————————————————————————————————————————————————————————— 0. Tooltips {
T0 = 'Small font size recommended for mobile app or multiple layout'
T1 = 'Tick to hide'
// }
// ————————————————————————————————————————————————————————————————————————————— 1. Inputs for table {
i_s_font    = input.string('normal',       'Font size', tooltip = T0, options = ['tiny', 'small',  'normal', 'large', 'huge'])
i_s_Y       = input.string('top',     'Table Position', inline = '0', options = ['top',  'middle', 'bottom'])
i_s_X       = input.string('right',                 '', inline = '0', options = ['left', 'center', 'right'])
i_c_text    = input.color(color.black,          'Text')
i_c_bg      = input.color(color.white,    'Background')
i_c_border  = input.color(color.black,        'Border')
// }
// ————————————————————————————————————————————————————————————————————————————— 2. Inputs for array {
i_b_basecurrency = input.bool(false, 'basecurrency', inline ='1', group = 'syminfo')
i_b_currency     = input.bool(false, 'currency    ', inline ='2', group = 'syminfo')
i_b_description  = input.bool(false, 'description ', inline ='3', group = 'syminfo')
i_b_mintick      = input.bool(false, 'mintick     ', inline ='4', group = 'syminfo')
i_b_pointvalue   = input.bool(false, 'pointvalue  ', inline ='5', group = 'syminfo')
i_b_prefix       = input.bool(false, 'prefix      ', inline ='6', group = 'syminfo')
i_b_root         = input.bool(false, 'root',         inline ='1', group = 'syminfo', tooltip = T1)
i_b_session      = input.bool(false, 'session',      inline ='2', group = 'syminfo')
i_b_ticker       = input.bool(false, 'ticker',       inline ='3', group = 'syminfo')
i_b_tickerid     = input.bool(false, 'tickerid',     inline ='4', group = 'syminfo')
i_b_timezone     = input.bool(false, 'timezone',     inline ='5', group = 'syminfo')
i_b_type         = input.bool(false, 'type',         inline ='6', group = 'syminfo')
// }
// ————————————————————————————————————————————————————————————————————————————— 3. New array {
arr_info          = array.new_string(12)
arr_syminfo       = array.new_string(12)
table[] arr_table = array.new_table()
// }
// ————————————————————————————————————————————————————————————————————————————— 4. Custom functions {
f_table_top() => table.new(position = i_s_Y + '_' + i_s_X, rows = 12, columns = 2, frame_color = i_c_border, frame_width = 1, border_color = i_c_border, border_width = 1)

f_set(int _index, string _value1, string _value2) =>
    array.set(arr_info,    _index, _value1)
    array.set(arr_syminfo, _index, _value2)

f_input(bool _input, int _row) =>
    if _input
        table.clear(array.get(arr_table, 0), 0, _row, 1, _row)
// }
// ————————————————————————————————————————————————————————————————————————————— 5. array values push / set {
array.push(arr_table, f_table_top())

f_set( 0, 'basecurrency', syminfo.basecurrency)
f_set( 1,     'currency', syminfo.currency)
f_set( 2,  'description', syminfo.description)
f_set( 3,      'mintick', str.tostring(syminfo.mintick))
f_set( 4,   'pointvalue', str.tostring(syminfo.pointvalue))
f_set( 5,       'prefix', syminfo.prefix)
f_set( 6,         'root', syminfo.root)
f_set( 7,      'session', syminfo.session)
f_set( 8,       'ticker', syminfo.ticker)
f_set( 9,     'tickerid', syminfo.tickerid)
f_set(10,     'timezone', syminfo.timezone)
f_set(11,         'type', syminfo.type)
// }
// ————————————————————————————————————————————————————————————————————————————— 6. Construct {
if barstate.islast
    for x = 0 to 11
        table.cell(array.get(arr_table, 0), 0, x, text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg, text = 'syminfo.' + array.get(arr_info, x), text_halign = text.align_left)
        table.cell(array.get(arr_table, 0), 1, x, text_color = i_c_text, text_size = i_s_font, bgcolor = i_c_bg, text = array.get(arr_syminfo, x))
    f_input(i_b_basecurrency, 0)
    f_input(i_b_currency,     1)
    f_input(i_b_description,  2)
    f_input(i_b_mintick,      3)
    f_input(i_b_pointvalue,   4)
    f_input(i_b_prefix,       5)
    f_input(i_b_root,         6)
    f_input(i_b_session,      7)
    f_input(i_b_ticker,       8)
    f_input(i_b_tickerid,     9)
    f_input(i_b_timezone,    10)
    f_input(i_b_type,        11)
// }