syminfo table
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © weak_hand

//@version=5
indicator("syminfo table", "syminfo", true)

string table_xpos = input.string("center", "X-Position", ["center", "left", "right"], display = display.none)
string table_ypos = input.string("middle", "Y-Position"  , ["bottom", "middle", "top"], display = display.none)
string table_size = input.string("auto", "Text Size", ["auto", "tiny", "small", "normal", "large", "huge"], display = display.none)
color  color_bg   = input.color(defval = color.yellow, title = "Background")
color  color_text = input.color(defval = color.black, title = "Text")
var table_syminfo = table.new(table_ypos + "_" + table_xpos, 2, 1, color_bg)

string nl    = "\n"
string left  = na
string right = na

if syminfo.type == "stock"
    left :=
      "syminfo.country: "                     + nl +
      "syminfo.currency: "                    + nl +
      "syminfo.description: "                 + nl +
      "syminfo.employees: "                   + nl +
      "syminfo.industry: "                    + nl +
      "syminfo.minmove: "                     + nl +
      "syminfo.mintick: "                     + nl +
      "syminfo.pointvalue: "                  + nl +
      "syminfo.prefix: "                      + nl +
      "syminfo.pricescale: "                  + nl +
      "syminfo.recommendations_buy: "         + nl +
      "syminfo.recommendations_buy_strong: "  + nl +
      "syminfo.recommendations_date: "        + nl +
      "syminfo.recommendations_hold: "        + nl +
      "syminfo.recommendations_sell: "        + nl +
      "syminfo.recommendations_sell_strong: " + nl +
      "syminfo.recommendations_total: "       + nl +
      "syminfo.root: "                        + nl +
      "syminfo.sector: "                      + nl +
      "syminfo.session: "                     + nl +
      "syminfo.shareholders: "                + nl +
      "syminfo.shares_outstanding_float: "    + nl +
      "syminfo.shares_outstanding_total: "    + nl +
      "syminfo.target_price_average: "        + nl +
      "syminfo.target_price_date: "           + nl +
      "syminfo.target_price_estimates: "      + nl +
      "syminfo.target_price_high: "           + nl +
      "syminfo.target_price_low: "            + nl +
      "syminfo.target_price_median: "         + nl +
      "syminfo.ticker: "                      + nl +
      "syminfo.tickerid: "                    + nl +
      "syminfo.timezone: "                    + nl +
      "syminfo.type: "                        + nl +
      "syminfo.volumetype: "
    
    right :=
      syminfo.country                                                               + nl +
      syminfo.currency                                                              + nl +
      syminfo.description                                                           + nl +
      str.tostring(syminfo.employees, format.volume)                                + nl +
      syminfo.industry                                                              + nl +
      str.tostring(syminfo.minmove)                                                 + nl +
      str.tostring(syminfo.mintick)                                                 + nl +
      str.tostring(syminfo.pointvalue)                                              + nl +
      syminfo.prefix                                                                + nl +
      str.tostring(syminfo.pricescale)                                              + nl +
      str.tostring(syminfo.recommendations_buy)                                     + nl +
      str.tostring(syminfo.recommendations_buy_strong)                              + nl +
      str.format_time(syminfo.recommendations_date, "yyyy-MM-dd", syminfo.timezone) + nl +
      str.tostring(syminfo.recommendations_hold)                                    + nl +
      str.tostring(syminfo.recommendations_sell)                                    + nl +
      str.tostring(syminfo.recommendations_sell_strong)                             + nl +
      str.tostring(syminfo.recommendations_total)                                   + nl +
      syminfo.root                                                                  + nl +
      syminfo.sector                                                                + nl +
      syminfo.session                                                               + nl +
      str.tostring(syminfo.shareholders, format.volume)                             + nl +
      str.tostring(syminfo.shares_outstanding_float, format.volume)                 + nl +
      str.tostring(syminfo.shares_outstanding_total, format.volume)                 + nl +
      str.tostring(syminfo.target_price_average, format.mintick)                    + nl +
      str.format_time(syminfo.target_price_date, "yyyy-MM-dd", syminfo.timezone)    + nl +
      str.tostring(syminfo.target_price_estimates, format.mintick)                  + nl +
      str.tostring(syminfo.target_price_high, format.mintick)                       + nl +
      str.tostring(syminfo.target_price_low, format.mintick)                        + nl +
      str.tostring(syminfo.target_price_median, format.mintick)                     + nl +
      syminfo.ticker                                                                + nl +
      syminfo.tickerid                                                              + nl +
      syminfo.timezone                                                              + nl +
      syminfo.type                                                                  + nl +
      syminfo.volumetype

else if syminfo.type == "fund"
    left :=
      "syminfo.country: "     + nl +
      "syminfo.currency: "    + nl +
      "syminfo.description: " + nl +
      "syminfo.industry: "    + nl +
      "syminfo.minmove: "     + nl +
      "syminfo.mintick: "     + nl +
      "syminfo.pointvalue: "  + nl +
      "syminfo.prefix: "      + nl +
      "syminfo.pricescale: "  + nl +
      "syminfo.root: "        + nl +
      "syminfo.sector: "      + nl +
      "syminfo.session: "     + nl +
      "syminfo.ticker: "      + nl +
      "syminfo.tickerid: "    + nl +
      "syminfo.timezone: "    + nl +
      "syminfo.type: "        + nl +
      "syminfo.volumetype: "
    
    right :=
      syminfo.country                   + nl +
      syminfo.currency                  + nl +
      syminfo.description               + nl +
      syminfo.industry                  + nl +
      str.tostring(syminfo.minmove)     + nl +
      str.tostring(syminfo.mintick)     + nl +
      str.tostring(syminfo.pointvalue)  + nl +
      syminfo.prefix                    + nl +
      str.tostring(syminfo.pricescale)  + nl +
      syminfo.root                      + nl +
      syminfo.sector                    + nl +
      syminfo.session                   + nl +
      syminfo.ticker                    + nl +
      syminfo.tickerid                  + nl +
      syminfo.timezone                  + nl +
      syminfo.type                      + nl +
      syminfo.volumetype

else if syminfo.type == "fund" or syminfo.type == "futures"
    left :=
      "syminfo.country: "     + nl +
      "syminfo.currency: "    + nl +
      "syminfo.description: " + nl +
      "syminfo.minmove: "     + nl +
      "syminfo.mintick: "     + nl +
      "syminfo.pointvalue: "  + nl +
      "syminfo.prefix: "      + nl +
      "syminfo.pricescale: "  + nl +
      "syminfo.root: "        + nl +
      "syminfo.session: "     + nl +
      "syminfo.ticker: "      + nl +
      "syminfo.tickerid: "    + nl +
      "syminfo.timezone: "    + nl +
      "syminfo.type: "        + nl +
      "syminfo.volumetype: "
    
    right :=
      syminfo.country                   + nl +
      syminfo.currency                  + nl +
      syminfo.description               + nl +
      str.tostring(syminfo.minmove)     + nl +
      str.tostring(syminfo.mintick)     + nl +
      str.tostring(syminfo.pointvalue)  + nl +
      syminfo.prefix                    + nl +
      str.tostring(syminfo.pricescale)  + nl +
      syminfo.root                      + nl +
      syminfo.session                   + nl +
      syminfo.ticker                    + nl +
      syminfo.tickerid                  + nl +
      syminfo.timezone                  + nl +
      syminfo.type                      + nl +
      syminfo.volumetype

else if syminfo.type == "forex" or syminfo.type == "crypto" or syminfo.type == "index"
    left :=
      "syminfo.basecurrency: "  + nl +
      "syminfo.currency: "      + nl +
      "syminfo.description: "   + nl +
      "syminfo.minmove: "       + nl +
      "syminfo.mintick: "       + nl +
      "syminfo.pointvalue: "    + nl +
      "syminfo.prefix: "        + nl +
      "syminfo.pricescale: "    + nl +
      "syminfo.root: "          + nl +
      "syminfo.session: "       + nl +
      "syminfo.ticker: "        + nl +
      "syminfo.tickerid: "      + nl +
      "syminfo.timezone: "      + nl +
      "syminfo.type: "          + nl +
      "syminfo.volumetype: "
    
    right :=
      syminfo.basecurrency              + nl +
      syminfo.currency                  + nl +
      syminfo.description               + nl +
      str.tostring(syminfo.minmove)     + nl +
      str.tostring(syminfo.mintick)     + nl +
      str.tostring(syminfo.pointvalue)  + nl +
      syminfo.prefix                    + nl +
      str.tostring(syminfo.pricescale)  + nl +
      syminfo.root                      + nl +
      syminfo.session                   + nl +
      syminfo.ticker                    + nl +
      syminfo.tickerid                  + nl +
      syminfo.timezone                  + nl +
      syminfo.type                      + nl +
      syminfo.volumetype

else if syminfo.type == "bond" or syminfo.type == "economic"
    left :=
      "syminfo.country: "                     + nl +
      "syminfo.description: "                 + nl +
      "syminfo.minmove: "                     + nl +
      "syminfo.mintick: "                     + nl +
      "syminfo.pointvalue: "                  + nl +
      "syminfo.prefix: "                      + nl +
      "syminfo.pricescale: "                  + nl +
      "syminfo.root: "                        + nl +
      "syminfo.session: "                     + nl +
      "syminfo.ticker: "                      + nl +
      "syminfo.tickerid: "                    + nl +
      "syminfo.timezone: "                    + nl +
      "syminfo.type: "                        + nl +
      "syminfo.volumetype: "
    
    right :=
      syminfo.country                                                               + nl +
      syminfo.description                                                           + nl +
      str.tostring(syminfo.minmove)                                                 + nl +
      str.tostring(syminfo.mintick)                                                 + nl +
      str.tostring(syminfo.pointvalue)                                              + nl +
      syminfo.prefix                                                                + nl +
      str.tostring(syminfo.pricescale)                                              + nl +
      syminfo.root                                                                  + nl +
      syminfo.session                                                               + nl +
      syminfo.ticker                                                                + nl +
      syminfo.tickerid                                                              + nl +
      syminfo.timezone                                                              + nl +
      syminfo.type                                                                  + nl +
      syminfo.volumetype

else
    left :=
      "syminfo.basecurrency: "                + nl +
      "syminfo.country: "                     + nl +
      "syminfo.currency: "                    + nl +
      "syminfo.description: "                 + nl +
      "syminfo.employees: "                   + nl +
      "syminfo.industry: "                    + nl +
      "syminfo.minmove: "                     + nl +
      "syminfo.mintick: "                     + nl +
      "syminfo.pointvalue: "                  + nl +
      "syminfo.prefix: "                      + nl +
      "syminfo.pricescale: "                  + nl +
      "syminfo.recommendations_buy: "         + nl +
      "syminfo.recommendations_buy_strong: "  + nl +
      "syminfo.recommendations_date: "        + nl +
      "syminfo.recommendations_hold: "        + nl +
      "syminfo.recommendations_sell: "        + nl +
      "syminfo.recommendations_sell_strong: " + nl +
      "syminfo.recommendations_total: "       + nl +
      "syminfo.root: "                        + nl +
      "syminfo.sector: "                      + nl +
      "syminfo.session: "                     + nl +
      "syminfo.shareholders: "                + nl +
      "syminfo.shares_outstanding_float: "    + nl +
      "syminfo.shares_outstanding_total: "    + nl +
      "syminfo.target_price_average: "        + nl +
      "syminfo.target_price_date: "           + nl +
      "syminfo.target_price_estimates: "      + nl +
      "syminfo.target_price_high: "           + nl +
      "syminfo.target_price_low: "            + nl +
      "syminfo.target_price_median: "         + nl +
      "syminfo.ticker: "                      + nl +
      "syminfo.tickerid: "                    + nl +
      "syminfo.timezone: "                    + nl +
      "syminfo.type: "                        + nl +
      "syminfo.volumetype: "
    
    right :=
      syminfo.basecurrency                                                          + nl +
      syminfo.country                                                               + nl +
      syminfo.currency                                                              + nl +
      syminfo.description                                                           + nl +
      str.tostring(syminfo.employees, format.volume)                                + nl +
      syminfo.industry                                                              + nl +
      str.tostring(syminfo.minmove)                                                 + nl +
      str.tostring(syminfo.mintick)                                                 + nl +
      str.tostring(syminfo.pointvalue)                                              + nl +
      syminfo.prefix                                                                + nl +
      str.tostring(syminfo.pricescale)                                              + nl +
      str.tostring(syminfo.recommendations_buy)                                     + nl +
      str.tostring(syminfo.recommendations_buy_strong)                              + nl +
      str.format_time(syminfo.recommendations_date, "yyyy-MM-dd", syminfo.timezone) + nl +
      str.tostring(syminfo.recommendations_hold)                                    + nl +
      str.tostring(syminfo.recommendations_sell)                                    + nl +
      str.tostring(syminfo.recommendations_sell_strong)                             + nl +
      str.tostring(syminfo.recommendations_total)                                   + nl +
      syminfo.root                                                                  + nl +
      syminfo.sector                                                                + nl +
      syminfo.session                                                               + nl +
      str.tostring(syminfo.shareholders, format.volume)                             + nl +
      str.tostring(syminfo.shares_outstanding_float, format.volume)                 + nl +
      str.tostring(syminfo.shares_outstanding_total, format.volume)                 + nl +
      str.tostring(syminfo.target_price_average, format.mintick)                    + nl +
      str.format_time(syminfo.target_price_date, "yyyy-MM-dd", syminfo.timezone)    + nl +
      str.tostring(syminfo.target_price_estimates, format.mintick)                  + nl +
      str.tostring(syminfo.target_price_high, format.mintick)                       + nl +
      str.tostring(syminfo.target_price_low, format.mintick)                        + nl +
      str.tostring(syminfo.target_price_median, format.mintick)                     + nl +
      syminfo.ticker                                                                + nl +
      syminfo.tickerid                                                              + nl +
      syminfo.timezone                                                              + nl +
      syminfo.type                                                                  + nl +
      syminfo.volumetype

if barstate.isfirst
    table_syminfo.cell(0, 0, left , text_color = color_text, text_halign = text.align_right, text_size = table_size)
    table_syminfo.cell(1, 0, "---", text_color = color_text, text_halign = text.align_left , text_size = table_size)
else if barstate.islastconfirmedhistory
    table_syminfo.cell_set_text(1, 0, right)
