Financial Data Spreadsheet [By MUQWISHI]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://Mozilla.org/MPL/2.0/
// Developed By © MUQWISHI

//@version=5
indicator("Financial Data Spreadsheet", overlay = true)

// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// |                                   INPUT                                    |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// Table Style
// Position 
tablePos = input.string("Top Right", "Location  ‏ ", 
             ["Top Right" , "Middle Right"  , "Bottom Right" , 
              "Top Center", "Middle Center" , "Bottom Center", 
              "Top Left"  , "Middle Left"   , "Bottom Left" ], group = "Table Location & Size", inline = "1")
    
// Size
tableSiz = input.string("Small", " Size", 
             ["Auto",  "Huge",  "Large", "Normal", "Small", "Tiny"], group = "Table Location & Size", inline = "1")


// Horizontal & Vertical Adjustment 
hrzAdj = input.float(0, "Adjustment", step = 0.2, group = "Table Location & Size", inline = "2")
vrtAdj = input.float(0, "  - ",       step = 0.2, group = "Table Location & Size", inline = "2", 
         tooltip = "To Adjust Table Location (Horizontally - Vertically)\n" +
         "First filed for Horizontal adjustment.\nSecond field for Vertical adjustment.\n\n" +
         "From its default location\n" +
         "- Positive Horizontal value to move it Right.\n- Negative Horizontal value to move it Left.\n" +
         "- Positive Vertical value to move it Up.\n- Negative Vertical value to move it Down.")

hidTitl = input.bool(false, "Hide Columns Title?",     group = "Table Location & Size")
hidsyms = input.bool(false, "Hide Instrument Column?", group = "Table Location & Size")

// Main Colors
tBgCol   = input.color(#696969, "Column Title", group = "Tbale Color", inline = "4")
cClCol   = input.color(#A9A9A9, " Cell",        group = "Tbale Color", inline = "4")
txtCol   = input.color(color.white, " Text",    group = "Tbale Color", inline = "4")

cShdCol  = input.bool(true, "Shade Alternate Rows", group = "Tbale Color")

// ++++++ Technical
prid  = input.string("Quarter", "Financial Period     ‏", ["Year", "Quarter"],   group = "Technical")
curn  = input.string("USD", "Currency",                                                 group = "Technical")


// ++++++ Columns
// Col#1
col01 = input.string("Total Revenue", "Column №1", ["None",
         "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ BALANCE SHEET ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡", "Accounts Payable","Accounts Receivable - Trade, Net","Accrued Payroll","Accumulated Depreciation, Total","Additional Paid-in Capital/Capital Surplus","Book Value Per Share","Capital and Operating Lease Obligations","Capitalized Lease Obligations","Cash & Equivalents","Cash and Short Term Investments","Common Equity, Total","Common Stock Par/Carrying Value","Current Portion of LT debt and Capital Leases","Deferred Income, Current","Deferred Income, Non-current","Deferred Tax Assets","Deferred Tax Liabilities","Dividends Payable","Goodwill, Net","Gross Property/Plant/Equipment","Income Tax Payable","Inventories - Finished Goods","Inventories - Progress Payments & Other","Inventories - Raw Materials","Inventories - Work in Progress","Investments in Unconsolidated Subsidiaries","Long Term Debt","Long Term Debt Excl. Lease Liabilities","Long Term Investments","Minority Interest","Net Debt","Net Intangible Assets","Net Property/Plant/Equipment","Note Receivable - Long Term","Notes Payable","Operating Lease Liabilities","Other Common Equity","Other Current Assets, Total","Other Current Liabilities","Other Intangibles, Net","Other Investments","Other Long Term Assets, Total","Other Non-current Liabilities, Total","Other Receivables","Other Short Term Debt","Paid in Capital","Preferred Stock, Carrying Value","Prepaid Expenses","Provision for Risks & Charge","Retained Earnings","Shareholders' Equity","Short Term Debt","Short Term Debt Excl. Current Portion of LT debt","Short Term Investments","Tangible Book Value Per Share","Total Assets","Total Current Assets","Total Current Liabilities","Total Debt","Total Equity","Total Inventory","Total Liabilities","Total Liabilities & Shareholders' Equities","Total Non-current Assets","Total Non-current Liabilities","Total Receivables, Net","Treasury Stock - Common", "",
         "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ CASH FLOW ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡", "Amortization","Capital Expenditures","Capital Expenditures - Fixed Assets","Capital Expenditures - Other Assets","Cash From Financing Activities","Cash From Investing Activities","Cash From Operating Activities","Change in Accounts Payable","Change in Accounts Receivable","Change in Accrued Expenses","Change in Inventories","Change in Other Assets/Liabilities","Change in Taxes Payable","Changes in Working Capital","Common Dividends Paid","Deferred Taxes (Cash Flow)","Depreciation & Amortization (Cash Flow)","Depreciation/depletion","Financing Activities – Other Sources","Financing Activities – Other Uses","Free Cash Flow","Funds From Operations","Investing Activities – Other Sources","Investing Activities – Other Uses","Issuance of Long Term Debt","Issuance/Retirement of Debt, Net","Issuance/Retirement of Long Term Debt","Issuance/Retirement of Other Debt","Issuance/Retirement of Short Term Debt","Issuance/Retirement of Stock, Net","Net Income (Cash Flow)","Non-cash Items","Other Financing Cash Flow Items, Total","Other Investing Cash Flow Items, Total","Preferred Dividends Paid","Purchase of Investments","Purchase/Acquisition of Business","Purchase/Sale of Business, Net","Purchase/Sale of Investments, Net","Reduction of Long Term Debt","Repurchase of Common & Preferred Stock","Sale of Common & Preferred Stock","Sale of Fixed Assets & Businesses","Sale/Maturity of Investments","Total Cash Dividends Paid", " ",
         "≡≡≡≡≡≡≡≡≡≡≡≡≡ INCOME STATEMENTS ≡≡≡≡≡≡≡≡≡≡≡≡≡", "After Tax Other Income/Expense","Average Basic Shares Outstanding","Basic Earnings Per Share (Basic EPS)","Cost of Goods Sold","Deprecation and Amortization","Diluted Earnings Per Share (Diluted EPS)","Diluted Net Income Available to Common Stockholders","Diluted Shares Outstanding","Dilution Adjustment","Discontinued Operations","EBIT","EBITDA","Equity in Earnings","Gross Profit","Interest Capitalized","Interest Expense on Debt","Interest Expense, Net of Interest Capitalized","Miscellaneous Non-operating Expense","Net Income","Net Income Before Discontinued Operations","Non-controlling/Minority Interest","Non-operating Income, Excl. Interest Expenses","Non-operating Income, Total","Non-operating Interest Income","Operating Expenses (Excl. COGS)","Operating Income","Other Cost of Goods Sold","Other Operating Expenses, Total","Preferred Dividends","Pretax Equity in Earnings","Pretax Income","Research & Development","Selling/General/Admin Expenses, Other","Selling/General/Admin Expenses, Total","Taxes","Total Operating Expenses","Total Revenue","Unusual Income/Expense", "  ",
         "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ STATISTICS ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ ", "Accruals","Altman Z-score","Asset Turnover","Beneish M-score","Buyback Yield %","COGS to Revenue Ratio","Cash Conversion Cycle","Cash to Debt Ratio","Current Ratio","Days Inventory","Days Payable","Days Sales Outstanding","Debt to EBITDA Ratio","Debt to Assets Ratio","Debt to Equity Ratio","Debt to Revenue Ratio","Dividend Payout Ratio %","Dividend Yield %","Dividends Per Share - Common Stock Primary Issue","EBITDA Margin %","EPS Basic One Year Growth","EPS Diluted One Year Growth","EPS Estimates","Effective Interest Rate on Debt %","Enterprise Value","Enterprise Value to EBIT Ratio","Enterprise Value to EBITDA Ratio","Enterprise Value to Revenue Ratio","Equity to Assets Ratio","Float Shares Outstanding","Free Cash Flow Margin %","Fulmer H Factor","Goodwill to Assets Ratio","Graham's Number","Gross Margin %","Gross Profit to Assets Ratio","Interest Coverage","Inventory to Revenue Ratio","Inventory Turnover","KZ Index","Long Term Debt to Total Assets Ratio","Net Current Asset Value Per Share","Net Income Per Employee","Net Margin %","Number of Employees","Operating Earnings Yield %","Operating Margin %","PEG Ratio","Piotroski F-score","Price Earnings Ratio Forward","Price Sales Ratio Forward","Quality Ratio","Quick Ratio","Research & Development to Revenue Ratio","Return on Assets %","Return on Common Equity %","Return on Equity %","Return on Equity Adjusted to Book Value %","Return on Invested Capital %","Return on Tangible Assets %","Return on Tangible Equity %","Revenue Estimates","Revenue One Year Growth","Revenue Per Employee","Shares Buyback Ratio %","Sloan Ratio %","Springate Score","Sustainable Growth Rate","Tangible Common Equity Ratio","Tobin's Q (Approximate)","Total Common Shares Outstanding","Zmijewski Score"],
         group = "Column №1")

chk01 = input.bool(false, "HL",          group = "Column №1", inline = "0")
h01mn = input.float(-1000000000000, "",  group = "Column №1", inline = "0")
h01mx = input.float( 1000000000000, "-", group = "Column №1", inline = "0", tooltip = "Highlight Value between MIN and MAX")
clr01 = input.color(color.aqua, "",    group = "Column №1", inline = "0")

// Col#2
col02 = input.string("Gross Profit", "Column №2", ["None",
         "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ BALANCE SHEET ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡", "Accounts Payable","Accounts Receivable - Trade, Net","Accrued Payroll","Accumulated Depreciation, Total","Additional Paid-in Capital/Capital Surplus","Book Value Per Share","Capital and Operating Lease Obligations","Capitalized Lease Obligations","Cash & Equivalents","Cash and Short Term Investments","Common Equity, Total","Common Stock Par/Carrying Value","Current Portion of LT debt and Capital Leases","Deferred Income, Current","Deferred Income, Non-current","Deferred Tax Assets","Deferred Tax Liabilities","Dividends Payable","Goodwill, Net","Gross Property/Plant/Equipment","Income Tax Payable","Inventories - Finished Goods","Inventories - Progress Payments & Other","Inventories - Raw Materials","Inventories - Work in Progress","Investments in Unconsolidated Subsidiaries","Long Term Debt","Long Term Debt Excl. Lease Liabilities","Long Term Investments","Minority Interest","Net Debt","Net Intangible Assets","Net Property/Plant/Equipment","Note Receivable - Long Term","Notes Payable","Operating Lease Liabilities","Other Common Equity","Other Current Assets, Total","Other Current Liabilities","Other Intangibles, Net","Other Investments","Other Long Term Assets, Total","Other Non-current Liabilities, Total","Other Receivables","Other Short Term Debt","Paid in Capital","Preferred Stock, Carrying Value","Prepaid Expenses","Provision for Risks & Charge","Retained Earnings","Shareholders' Equity","Short Term Debt","Short Term Debt Excl. Current Portion of LT debt","Short Term Investments","Tangible Book Value Per Share","Total Assets","Total Current Assets","Total Current Liabilities","Total Debt","Total Equity","Total Inventory","Total Liabilities","Total Liabilities & Shareholders' Equities","Total Non-current Assets","Total Non-current Liabilities","Total Receivables, Net","Treasury Stock - Common",  "", 
         "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ CASH FLOW ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡", "Amortization","Capital Expenditures","Capital Expenditures - Fixed Assets","Capital Expenditures - Other Assets","Cash From Financing Activities","Cash From Investing Activities","Cash From Operating Activities","Change in Accounts Payable","Change in Accounts Receivable","Change in Accrued Expenses","Change in Inventories","Change in Other Assets/Liabilities","Change in Taxes Payable","Changes in Working Capital","Common Dividends Paid","Deferred Taxes (Cash Flow)","Depreciation & Amortization (Cash Flow)","Depreciation/depletion","Financing Activities – Other Sources","Financing Activities – Other Uses","Free Cash Flow","Funds From Operations","Investing Activities – Other Sources","Investing Activities – Other Uses","Issuance of Long Term Debt","Issuance/Retirement of Debt, Net","Issuance/Retirement of Long Term Debt","Issuance/Retirement of Other Debt","Issuance/Retirement of Short Term Debt","Issuance/Retirement of Stock, Net","Net Income (Cash Flow)","Non-cash Items","Other Financing Cash Flow Items, Total","Other Investing Cash Flow Items, Total","Preferred Dividends Paid","Purchase of Investments","Purchase/Acquisition of Business","Purchase/Sale of Business, Net","Purchase/Sale of Investments, Net","Reduction of Long Term Debt","Repurchase of Common & Preferred Stock","Sale of Common & Preferred Stock","Sale of Fixed Assets & Businesses","Sale/Maturity of Investments","Total Cash Dividends Paid", " ",
         "≡≡≡≡≡≡≡≡≡≡≡≡≡ INCOME STATEMENTS ≡≡≡≡≡≡≡≡≡≡≡≡≡", "After Tax Other Income/Expense","Average Basic Shares Outstanding","Basic Earnings Per Share (Basic EPS)","Cost of Goods Sold","Deprecation and Amortization","Diluted Earnings Per Share (Diluted EPS)","Diluted Net Income Available to Common Stockholders","Diluted Shares Outstanding","Dilution Adjustment","Discontinued Operations","EBIT","EBITDA","Equity in Earnings","Gross Profit","Interest Capitalized","Interest Expense on Debt","Interest Expense, Net of Interest Capitalized","Miscellaneous Non-operating Expense","Net Income","Net Income Before Discontinued Operations","Non-controlling/Minority Interest","Non-operating Income, Excl. Interest Expenses","Non-operating Income, Total","Non-operating Interest Income","Operating Expenses (Excl. COGS)","Operating Income","Other Cost of Goods Sold","Other Operating Expenses, Total","Preferred Dividends","Pretax Equity in Earnings","Pretax Income","Research & Development","Selling/General/Admin Expenses, Other","Selling/General/Admin Expenses, Total","Taxes","Total Operating Expenses","Total Revenue","Unusual Income/Expense", "  ",
         "≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ STATISTICS ≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡ ", "Accruals","Altman Z-score","Asset Turnover","Beneish M-score","Buyback Yield %","COGS to Revenue Ratio","Cash Conversion Cycle","Cash to Debt Ratio","Current Ratio","Days Inventory","Days Payable","Days Sales Outstanding","Debt to EBITDA Ratio","Debt to Assets Ratio","Debt to Equity Ratio","Debt to Revenue Ratio","Dividend Payout Ratio %","Dividend Yield %","Dividends Per Share - Common Stock Primary Issue","EBITDA Margin %","EPS Basic One Year Growth","EPS Diluted One Year Growth","EPS Estimates","Effective Interest Rate on Debt %","Enterprise Value","Enterprise Value to EBIT Ratio","Enterprise Value to EBITDA Ratio","Enterprise Value to Revenue Ratio","Equity to Assets Ratio","Float Shares Outstanding","Free Cash Flow Margin %","Fulmer H Factor","Goodwill to Assets Ratio","Graham's Number","Gross Margin %","Gross Profit to Assets Ratio","Interest Coverage","Inventory to Revenue Ratio","Inventory Turnover","KZ Index","Long Term Debt to Total Assets Ratio","Net Current Asset Value Per Share","Net Income Per Employee","Net Margin %","Number of Employees","Operating Earnings Yield %","Operating Margin %","PEG Ratio","Piotroski F-score","Price Earnings Ratio Forward","Price Sales Ratio Forward","Quality Ratio","Quick Ratio","Research & Development to Revenue Ratio","Return on Assets %","Return on Common Equity %","Return on Equity %","Return on Equity Adjusted to Book Value %","Return on Invested Capital %","Return on Tangible Assets %","Return on Tangible Equity %","Revenue Estimates","Revenue One Year Growth","Revenue Per Employee","Shares Buyback Ratio %","Sloan Ratio %","Springate Score","Sustainable Growth Rate","Tangible Common Equity Ratio","Tobin's Q (Approximate)","Total Common Shares Outstanding","Zmijewski Score"],
         group = "Column №2")

chk02 = input.bool(false, "HL",          group = "Column №2", inline = "0")
h02mn = input.float(-1000000000000, "",  group = "Column №2", inline = "0")
h02mx = input.float( 1000000000000, "-", group = "Column №2", inline = "0", tooltip = "Highlight Value between MIN and MAX")
clr02 = input.color(color.aqua, "",    group = "Column №2", inline = "0")


// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// |                                  SYMBOLS                                   |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// Symbols Checkmark
// [1] Symbol
c01 = input.bool(true,  title = "", group = "Instruments", inline = "s01")
c02 = input.bool(true,  title = "", group = "Instruments", inline = "s02")
c03 = input.bool(true,  title = "", group = "Instruments", inline = "s03")
c04 = input.bool(true,  title = "", group = "Instruments", inline = "s04")
c05 = input.bool(true,  title = "", group = "Instruments", inline = "s05")
c06 = input.bool(true,  title = "", group = "Instruments", inline = "s06")
c07 = input.bool(true,  title = "", group = "Instruments", inline = "s07")
c08 = input.bool(true,  title = "", group = "Instruments", inline = "s08")
c09 = input.bool(true,  title = "", group = "Instruments", inline = "s09")
c10 = input.bool(true,  title = "", group = "Instruments", inline = "s10")
c11 = input.bool(true,  title = "", group = "Instruments", inline = "s11")
c12 = input.bool(true,  title = "", group = "Instruments", inline = "s12")
c13 = input.bool(true,  title = "", group = "Instruments", inline = "s13")
c14 = input.bool(true,  title = "", group = "Instruments", inline = "s14")
c15 = input.bool(true,  title = "", group = "Instruments", inline = "s15")
c16 = input.bool(true,  title = "", group = "Instruments", inline = "s16")
c17 = input.bool(true,  title = "", group = "Instruments", inline = "s17")
c18 = input.bool(true,  title = "", group = "Instruments", inline = "s18")
c19 = input.bool(true,  title = "", group = "Instruments", inline = "s19")
c20 = input.bool(true,  title = "", group = "Instruments", inline = "s20")

// [2] Symbol Input
s01 = input.symbol("BA",   title = "", group = "Instruments", inline = "s01")
s02 = input.symbol("TSLA", title = "", group = "Instruments", inline = "s02")
s03 = input.symbol("AAPL", title = "", group = "Instruments", inline = "s03")
s04 = input.symbol("META", title = "", group = "Instruments", inline = "s04")
s05 = input.symbol("AMZN", title = "", group = "Instruments", inline = "s05")
s06 = input.symbol("MSFT", title = "", group = "Instruments", inline = "s06")
s07 = input.symbol("NVDA", title = "", group = "Instruments", inline = "s07")
s08 = input.symbol("AMD",  title = "", group = "Instruments", inline = "s08")
s09 = input.symbol("F",    title = "", group = "Instruments", inline = "s09")
s10 = input.symbol("BAC",  title = "", group = "Instruments", inline = "s10")
s11 = input.symbol("INTC", title = "", group = "Instruments", inline = "s11")
s12 = input.symbol("GOOG", title = "", group = "Instruments", inline = "s12")
s13 = input.symbol("SHOP", title = "", group = "Instruments", inline = "s13")
s14 = input.symbol("UBER", title = "", group = "Instruments", inline = "s14")
s15 = input.symbol("BABA", title = "", group = "Instruments", inline = "s15")
s16 = input.symbol("OXY",  title = "", group = "Instruments", inline = "s16")
s17 = input.symbol("PLUG", title = "", group = "Instruments", inline = "s17")
s18 = input.symbol("KO",   title = "", group = "Instruments", inline = "s18")
s19 = input.symbol("SQ",   title = "", group = "Instruments", inline = "s19")
s20 = input.symbol("JPM",  title = "", group = "Instruments", inline = "s20")

// [3] Get Symbol Name
only_symbol(s) => 
    array.get(str.split(s, ":"), 1)


// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// |                                FINANCIAL ID                                |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
finId(id) =>
    switch id
        // Balance Sheet 
        "Accounts Payable"                                        => "ACCOUNTS_PAYABLE"
        "Accounts Receivable - Trade, Net"                        => "ACCOUNTS_RECEIVABLES_NET"
        "Accrued Payroll"                                         => "ACCRUED_PAYROLL"
        "Accumulated Depreciation, Total"                         => "ACCUM_DEPREC_TOTAL"
        "Additional Paid-in Capital/Capital Surplus"              => "ADDITIONAL_PAID_IN_CAPITAL"
        "Book Value Per Share"                                    => "BOOK_VALUE_PER_SHARE"
        "Capital and Operating Lease Obligations"                 => "CAPITAL_OPERATING_LEASE_OBLIGATIONS"
        "Capitalized Lease Obligations"                           => "CAPITAL_LEASE_OBLIGATIONS"
        "Cash & Equivalents"                                      => "CASH_N_EQUIVALENTS"
        "Cash and Short Term Investments"                         => "CASH_N_SHORT_TERM_INVEST"
        "Common Equity, Total"                                    => "COMMON_EQUITY_TOTAL"
        "Common Stock Par/Carrying Value"                         => "COMMON_STOCK_PAR"
        "Current Portion of LT debt and Capital Leases"           => "CURRENT_PORT_DEBT_CAPITAL_LEASES"
        "Deferred Income, Current"                                => "DEFERRED_INCOME_CURRENT"
        "Deferred Income, Non-current"                            => "DEFERRED_INCOME_NON_CURRENT"
        "Deferred Tax Assets"                                     => "DEFERRED_TAX_ASSESTS"
        "Deferred Tax Liabilities"                                => "DEFERRED_TAX_LIABILITIES"
        "Dividends Payable"                                       => "DIVIDENDS_PAYABLE"
        "Goodwill, Net"                                           => "GOODWILL"
        "Gross Property/Plant/Equipment"                          => "PPE_TOTAL_GROSS"
        "Income Tax Payable"                                      => "INCOME_TAX_PAYABLE"
        "Inventories - Finished Goods"                            => "INVENTORY_FINISHED_GOODS"
        "Inventories - Progress Payments & Other"                 => "INVENTORY_PROGRESS_PAYMENTS"
        "Inventories - Raw Materials"                             => "INVENTORY_RAW_MATERIALS"
        "Inventories - Work in Progress"                          => "INVENTORY_WORK_IN_PROGRESS"
        "Investments in Unconsolidated Subsidiaries"              => "INVESTMENTS_IN_UNCONCSOLIDATE"
        "Long Term Debt"                                          => "LONG_TERM_DEBT"
        "Long Term Debt Excl. Lease Liabilities"                  => "LONG_TERM_DEBT_EXCL_CAPITAL_LEASE"
        "Long Term Investments"                                   => "LONG_TERM_INVESTMENTS"
        "Minority Interest"                                       => "MINORITY_INTEREST"
        "Net Debt"                                                => "NET_DEBT"
        "Net Intangible Assets"                                   => "INTANGIBLES_NET"
        "Net Property/Plant/Equipment"                            => "PPE_TOTAL_NET"
        "Note Receivable - Long Term"                             => "LONG_TERM_NOTE_RECEIVABLE"
        "Notes Payable"                                           => "NOTES_PAYABLE_SHORT_TERM_DEBT"
        "Operating Lease Liabilities"                             => "OPERATING_LEASE_LIABILITIES"
        "Other Common Equity"                                     => "OTHER_COMMON_EQUITY"
        "Other Current Assets, Total"                             => "OTHER_CURRENT_ASSETS_TOTAL"
        "Other Current Liabilities"                               => "OTHER_CURRENT_LIABILITIES"
        "Other Intangibles, Net"                                  => "OTHER_INTANGIBLES_NET"
        "Other Investments"                                       => "OTHER_INVESTMENTS"
        "Other Long Term Assets, Total"                           => "LONG_TERM_OTHER_ASSETS_TOTAL"
        "Other Non-current Liabilities, Total"                    => "OTHER_LIABILITIES_TOTAL"
        "Other Receivables"                                       => "OTHER_RECEIVABLES"
        "Other Short Term Debt"                                   => "OTHER_SHORT_TERM_DEBT"
        "Paid in Capital"                                         => "PAID_IN_CAPITAL"
        "Preferred Stock, Carrying Value"                         => "PREFERRED_STOCK_CARRYING_VALUE"
        "Prepaid Expenses"                                        => "PREPAID_EXPENSES"
        "Provision for Risks & Charge"                            => "PROVISION_F_RISKS"
        "Retained Earnings"                                       => "RETAINED_EARNINGS"
        "Shareholders' Equity"                                    => "SHRHLDRS_EQUITY"
        "Short Term Debt"                                         => "SHORT_TERM_DEBT"
        "Short Term Debt Excl. Current Portion of LT debt"        => "SHORT_TERM_DEBT_EXCL_CURRENT_PORT"
        "Short Term Investments"                                  => "SHORT_TERM_INVEST"
        "Tangible Book Value Per Share"                           => "BOOK_TANGIBLE_PER_SHARE"
        "Total Assets"                                            => "TOTAL_ASSETS"
        "Total Current Assets"                                    => "TOTAL_CURRENT_ASSETS"
        "Total Current Liabilities"                               => "TOTAL_CURRENT_LIABILITIES"
        "Total Debt"                                              => "TOTAL_DEBT"
        "Total Equity"                                            => "TOTAL_EQUITY"
        "Total Inventory"                                         => "TOTAL_INVENTORY"
        "Total Liabilities"                                       => "TOTAL_LIABILITIES"
        "Total Liabilities & Shareholders' Equities"              => "TOTAL_LIABILITIES_SHRHLDRS_EQUITY"
        "Total Non-current Assets"                                => "TOTAL_NON_CURRENT_ASSETS"
        "Total Non-current Liabilities"                           => "TOTAL_NON_CURRENT_LIABILITIES"
        "Total Receivables, Net"                                  => "TOTAL_RECEIVABLES_NET"
        "Treasury Stock - Common"                                 => "TREASURY_STOCK_COMMON"
        
        // Cash flow
        "Amortization"                                            => "AMORTIZATION"
        "Capital Expenditures"                                    => "CAPITAL_EXPENDITURES"
        "Capital Expenditures - Fixed Assets"                     => "CAPITAL_EXPENDITURES_FIXED_ASSETS"
        "Capital Expenditures - Other Assets"                     => "CAPITAL_EXPENDITURES_OTHER_ASSETS"
        "Cash From Financing Activities"                          => "CASH_F_FINANCING_ACTIVITIES"
        "Cash From Investing Activities"                          => "CASH_F_INVESTING_ACTIVITIES"
        "Cash From Operating Activities"                          => "CASH_F_OPERATING_ACTIVITIES"
        "Change in Accounts Payable"                              => "CHANGE_IN_ACCOUNTS_PAYABLE"
        "Change in Accounts Receivable"                           => "CHANGE_IN_ACCOUNTS_RECEIVABLE"
        "Change in Accrued Expenses"                              => "CHANGE_IN_ACCRUED_EXPENSES"
        "Change in Inventories"                                   => "CHANGE_IN_INVENTORIES"
        "Change in Other Assets/Liabilities"                      => "CHANGE_IN_OTHER_ASSETS"
        "Change in Taxes Payable"                                 => "CHANGE_IN_TAXES_PAYABLE"
        "Changes in Working Capital"                              => "CHANGES_IN_WORKING_CAPITAL"
        "Common Dividends Paid"                                   => "COMMON_DIVIDENDS_CASH_FLOW"
        "Deferred Taxes (Cash Flow)"                              => "CASH_FLOW_DEFERRED_TAXES"
        "Depreciation & Amortization (Cash Flow)"                 => "CASH_FLOW_DEPRECATION_N_AMORTIZATION"
        "Depreciation/depletion"                                  => "DEPRECIATION_DEPLETION"
        "Financing Activities – Other Sources"                    => "OTHER_FINANCING_CASH_FLOW_SOURCES"
        "Financing Activities – Other Uses"                       => "OTHER_FINANCING_CASH_FLOW_USES"
        "Free Cash Flow"                                          => "FREE_CASH_FLOW"
        "Funds From Operations"                                   => "FUNDS_F_OPERATIONS"
        "Investing Activities – Other Sources"                    => "OTHER_INVESTING_CASH_FLOW_SOURCES"
        "Investing Activities – Other Uses"                       => "OTHER_INVESTING_CASH_FLOW_USES"
        "Issuance of Long Term Debt"                              => "SUPPLYING_OF_LONG_TERM_DEBT"
        "Issuance/Retirement of Debt, Net"                        => "ISSUANCE_OF_DEBT_NET"
        "Issuance/Retirement of Long Term Debt"                   => "ISSUANCE_OF_LONG_TERM_DEBT"
        "Issuance/Retirement of Other Debt"                       => "ISSUANCE_OF_OTHER_DEBT"
        "Issuance/Retirement of Short Term Debt"                  => "ISSUANCE_OF_SHORT_TERM_DEBT"
        "Issuance/Retirement of Stock, Net"                       => "ISSUANCE_OF_STOCK_NET"
        "Net Income (Cash Flow)"                                  => "NET_INCOME_STARTING_LINE"
        "Non-cash Items"                                          => "NON_CASH_ITEMS"
        "Other Financing Cash Flow Items, Total"                  => "OTHER_FINANCING_CASH_FLOW_ITEMS_TOTAL"
        "Other Investing Cash Flow Items, Total"                  => "OTHER_INVESTING_CASH_FLOW_ITEMS_TOTAL"
        "Preferred Dividends Paid"                                => "PREFERRED_DIVIDENDS_CASH_FLOW"
        "Purchase of Investments"                                 => "PURCHASE_OF_INVESTMENTS"
        "Purchase/Acquisition of Business"                        => "PURCHASE_OF_BUSINESS"
        "Purchase/Sale of Business, Net"                          => "PURCHASE_SALE_BUSINESS"
        "Purchase/Sale of Investments, Net"                       => "PURCHASE_SALE_INVESTMENTS"
        "Reduction of Long Term Debt"                             => "REDUCTION_OF_LONG_TERM_DEBT"
        "Repurchase of Common & Preferred Stock"                  => "PURCHASE_OF_STOCK"
        "Sale of Common & Preferred Stock"                        => "SALE_OF_STOCK"
        "Sale of Fixed Assets & Businesses"                       => "SALES_OF_BUSINESS"
        "Sale/Maturity of Investments"                            => "SALES_OF_INVESTMENTS"
        "Total Cash Dividends Paid"                               => "TOTAL_CASH_DIVIDENDS_PAID"
        
        // Income statements
        "After Tax Other Income/Expense"                          => "AFTER_TAX_OTHER_INCOME"
        "Average Basic Shares Outstanding"                        => "BASIC_SHARES_OUTSTANDING"
        "Basic Earnings Per Share (Basic EPS)"                    => "EARNINGS_PER_SHARE_BASIC"
        "Cost of Goods Sold"                                      => "COST_OF_GOODS"
        "Deprecation and Amortization"                            => "DEP_AMORT_EXP_INCOME_S"
        "Diluted Earnings Per Share (Diluted EPS)"                => "EARNINGS_PER_SHARE_DILUTED"
        "Diluted Net Income Available to Common Stockholders"     => "DILUTED_NET_INCOME"
        "Diluted Shares Outstanding"                              => "DILUTED_SHARES_OUTSTANDING"
        "Dilution Adjustment"                                     => "DILUTION_ADJUSTMENT"
        "Discontinued Operations"                                 => "DISCONTINUED_OPERATIONS"
        "EBIT"                                                    => "EBIT"
        "EBITDA"                                                  => "EBITDA"
        "Equity in Earnings"                                      => "EQUITY_IN_EARNINGS"
        "Gross Profit"                                            => "GROSS_PROFIT"
        "Interest Capitalized"                                    => "INTEREST_CAPITALIZED"
        "Interest Expense on Debt"                                => "INTEREST_EXPENSE_ON_DEBT"
        "Interest Expense, Net of Interest Capitalized"           => "NON_OPER_INTEREST_EXP"
        "Miscellaneous Non-operating Expense"                     => "OTHER_INCOME"
        "Net Income"                                              => "NET_INCOME"
        "Net Income Before Discontinued Operations"               => "NET_INCOME_BEF_DISC_OPER"
        "Non-controlling/Minority Interest"                       => "MINORITY_INTEREST_EXP"
        "Non-operating Income, Excl. Interest Expenses"           => "NON_OPER_INCOME"
        "Non-operating Income, Total"                             => "TOTAL_NON_OPER_INCOME"
        "Non-operating Interest Income"                           => "NON_OPER_INTEREST_INCOME"
        "Operating Expenses (Excl. COGS)"                         => "OPERATING_EXPENSES"
        "Operating Income"                                        => "OPER_INCOME"
        "Other Cost of Goods Sold"                                => "COST_OF_GOODS_EXCL_DEP_AMORT"
        "Other Operating Expenses, Total"                         => "OTHER_OPER_EXPENSE_TOTAL"
        "Preferred Dividends"                                     => "PREFERRED_DIVIDENDS"
        "Pretax Equity in Earnings"                               => "PRETAX_EQUITY_IN_EARNINGS"
        "Pretax Income"                                           => "PRETAX_INCOME"
        "Research & Development"                                  => "RESEARCH_AND_DEV"
        "Selling/General/Admin Expenses, Other"                   => "SELL_GEN_ADMIN_EXP_OTHER"
        "Selling/General/Admin Expenses, Total"                   => "SELL_GEN_ADMIN_EXP_TOTAL"
        "Taxes"                                                   => "INCOME_TAX"
        "Total Operating Expenses"                                => "TOTAL_OPER_EXPENSE"
        "Total Revenue"                                           => "TOTAL_REVENUE"
        "Unusual Income/Expense"                                  => "UNUSUAL_EXPENSE_INC"
        
        // Statistics
        "Accruals"                                                => "ACCRUALS_RATIO"
        "Altman Z-score"                                          => "ALTMAN_Z_SCORE"
        "Asset Turnover"                                          => "ASSET_TURNOVER"
        "Beneish M-score"                                         => "BENEISH_M_SCORE"
        "Buyback Yield %"                                         => "BUYBACK_YIELD"
        "COGS to Revenue Ratio"                                   => "COGS_TO_REVENUE"
        "Cash Conversion Cycle"                                   => "CASH_CONVERSION_CYCLE"
        "Cash to Debt Ratio"                                      => "CASH_TO_DEBT"
        "Current Ratio"                                           => "CURRENT_RATIO"
        "Days Inventory"                                          => "DAYS_INVENT"
        "Days Payable"                                            => "DAYS_PAY"
        "Days Sales Outstanding"                                  => "DAY_SALES_OUT"
        "Debt to EBITDA Ratio"                                    => "DEBT_TO_EBITDA"
        "Debt to Assets Ratio"                                    => "DEBT_TO_ASSET"
        "Debt to Equity Ratio"                                    => "DEBT_TO_EQUITY"
        "Debt to Revenue Ratio"                                   => "DEBT_TO_REVENUE"
        "Dividend Payout Ratio %"                                 => "DIVIDEND_PAYOUT_RATIO"
        "Dividend Yield %"                                        => "DIVIDENDS_YIELD"
        "Dividends Per Share - Common Stock Primary Issue"        => "DPS_COMMON_STOCK_PRIM_ISSUE"
        "EBITDA Margin %"                                         => "EBITDA_MARGIN"
        "EPS Basic One Year Growth"                               => "EARNINGS_PER_SHARE_BASIC_ONE_YEAR_GROWTH"
        "EPS Diluted One Year Growth"                             => "EARNINGS_PER_SHARE_DILUTED_ONE_YEAR_GROWTH"
        "EPS Estimates"                                           => "EARNINGS_ESTIMATE"
        "Effective Interest Rate on Debt %"                       => "EFFECTIVE_INTEREST_RATE_ON_DEBT"
        "Enterprise Value"                                        => "ENTERPRISE_VALUE"
        "Enterprise Value to EBIT Ratio"                          => "EV_EBIT"
        "Enterprise Value to EBITDA Ratio"                        => "ENTERPRISE_VALUE_EBITDA"
        "Enterprise Value to Revenue Ratio"                       => "EV_REVENUE"
        "Equity to Assets Ratio"                                  => "EQUITY_TO_ASSET"
        "Float Shares Outstanding"                                => "FLOAT_SHARES_OUTSTANDING"
        "Free Cash Flow Margin %"                                 => "FREE_CASH_FLOW_MARGIN"
        "Fulmer H Factor"                                         => "FULMER_H_FACTOR"
        "Goodwill to Assets Ratio"                                => "GOODWILL_TO_ASSET"
        "Graham's Number"                                         => "GRAHAM_NUMBERS"
        "Gross Margin %"                                          => "GROSS_MARGIN"
        "Gross Profit to Assets Ratio"                            => "GROSS_PROFIT_TO_ASSET"
        "Interest Coverage"                                       => "INTERST_COVER"
        "Inventory to Revenue Ratio"                              => "INVENT_TO_REVENUE"
        "Inventory Turnover"                                      => "INVENT_TURNOVER"
        "KZ Index"                                                => "KZ_INDEX"
        "Long Term Debt to Total Assets Ratio"                    => "LONG_TERM_DEBT_TO_ASSETS"
        "Net Current Asset Value Per Share"                       => "NCAVPS_RATIO"
        "Net Income Per Employee"                                 => "NET_INCOME_PER_EMPLOYEE"
        "Net Margin %"                                            => "NET_MARGIN"
        "Number of Employees"                                     => "NUMBER_OF_EMPLOYEES"
        "Operating Earnings Yield %"                              => "OPERATING_EARNINGS_YIELD"
        "Operating Margin %"                                      => "OPERATING_MARGIN"
        "PEG Ratio"                                               => "PEG_RATIO"
        "Piotroski F-score"                                       => "PIOTROSKI_F_SCORE"
        "Price Earnings Ratio Forward"                            => "PRICE_EARNINGS_FORWARD"
        "Price Sales Ratio Forward"                               => "PRICE_SALES_FORWARD"
        "Quality Ratio"                                           => "QUALITY_RATIO"
        "Quick Ratio"                                             => "QUICK_RATIO"
        "Research & Development to Revenue Ratio"                 => "RESEARCH_AND_DEVELOP_TO_REVENUE"
        "Return on Assets %"                                      => "RETURN_ON_ASSETS"
        "Return on Common Equity %"                               => "RETURN_ON_COMMON_EQUITY"
        "Return on Equity %"                                      => "RETURN_ON_EQUITY"
        "Return on Equity Adjusted to Book Value %"               => "RETURN_ON_EQUITY_ADJUST_TO_BOOK"
        "Return on Invested Capital %"                            => "RETURN_ON_INVESTED_CAPITAL"
        "Return on Tangible Assets %"                             => "RETURN_ON_TANG_ASSETS"
        "Return on Tangible Equity %"                             => "RETURN_ON_TANG_EQUITY"
        "Revenue Estimates"                                       => "SALES_ESTIMATES"
        "Revenue One Year Growth"                                 => "REVENUE_ONE_YEAR_GROWTH"
        "Revenue Per Employee"                                    => "REVENUE_PER_EMPLOYEE"
        "Shares Buyback Ratio %"                                  => "SHARE_BUYBACK_RATIO"
        "Sloan Ratio %"                                           => "SLOAN_RATIO"
        "Springate Score"                                         => "SPRINGATE_SCORE"
        "Sustainable Growth Rate"                                 => "SUSTAINABLE_GROWTH_RATE"
        "Tangible Common Equity Ratio"                            => "TANGIBLE_COMMON_EQUITY_RATIO"
        "Tobin's Q (Approximate)"                                 => "TOBIN_Q_RATIO"
        "Total Common Shares Outstanding"                         => "TOTAL_SHARES_OUTSTANDING"
        "Zmijewski Score"                                         => "ZMIJEWSKI_SCORE"
        
        => na

// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// |                                 COMPUTING                                  |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// Cell Color
highCol(chk, min, mix, val, col, x) =>
    out = x % 2 == 0 ? cClCol : (cShdCol ? color.new(cClCol, 20) : cClCol)
    if chk
        out := min <= val and mix >= val ? col : out
    out

// String Format
fmt(a, x) =>
    str.contains(a, "%") ? str.tostring(x, format.percent) : 
     math.abs(x) < 100000 ? str.tostring(x, "#.###") : str.tostring(x, format.volume)

// Input Columns 
inCol   = array.from("Instruments", col01, col02)

// Title Columns
titlCol = array.new<string>(na)
array.push(titlCol, "Instruments")

for i = 1 to array.size(inCol) - 1
    if not na(finId(array.get(inCol, i)))
        array.push(titlCol, array.get(inCol, i))

// Importing Financial Values
spreadSheet    = matrix.new<string>(na, array.size(titlCol),      na)
spreadSheetClr = matrix.new<color> (na, array.size(titlCol) , cClCol)

finVals(sym, chk) =>
    out   = array.new<string>(na)
    outCl = array.new<color>(na)

    out01 = request.financial(sym, finId(col01), prid == "Year" ? "FY" : "FQ", ignore_invalid_symbol = true, currency = curn)
    out02 = request.financial(sym, finId(col02), prid == "Year" ? "FY" : "FQ", ignore_invalid_symbol = true, currency = curn)
    
    if chk
        numRow = matrix.rows(spreadSheet)

        val   = array.from(out01, out02)
        valCl = array.from( 
                 highCol(chk01, h01mn, h01mx, out01, clr01, numRow),
                 highCol(chk02, h02mn, h02mx, out02, clr02, numRow))

        // Output
        array.push(out,   only_symbol(sym))
        array.push(outCl, not hidsyms ? (numRow % 2 == 0 ? cClCol : (cShdCol ? color.new(cClCol, 20) : cClCol)) : na)

        for i = 1 to array.size(inCol) - 1
            if not na(finId(array.get(inCol, i)))
                array.push(out,   fmt(array.get(inCol, i), array.get(val, i - 1)))
                array.push(outCl, array.get(valCl, i - 1))
        
        if array.size(inCol) > 0
            matrix.add_row(spreadSheet,    numRow,   out)
            matrix.add_row(spreadSheetClr, numRow, outCl)

finVals(s01, c01),  finVals(s02, c02),  finVals(s03, c03),  finVals(s04, c04),  finVals(s05, c05),  
finVals(s06, c06),  finVals(s07, c07),  finVals(s08, c08),  finVals(s09, c09),  finVals(s10, c10),  
finVals(s11, c11),  finVals(s12, c12),  finVals(s13, c13),  finVals(s14, c14),  finVals(s15, c15),  
finVals(s16, c16),  finVals(s17, c17),  finVals(s18, c18),  finVals(s19, c19),  finVals(s20, c20),

// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// |                                   TABLE                                    |
// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
// Get Tbale Location & Size
locNsze(x) => 
    y   = str.split(str.lower(x), " ")
    out = ""
    for i = 0 to array.size(y) - 1
        out := out + array.get(y, i)
        if i != array.size(y) - 1
            out := out + "_"
    out

// New Line for Long Title Name
title(x) =>
    y = str.split(x, " ")
    n = 0
    out = ""
    if x == "Instruments"
        out := "‏\n" + x +"\n‏ "
    else
        for i = 0 to array.size(y) - 1
            n += str.length(array.get(y, i))
            if n > 12
                out := out + array.get(y, i) + "\n"
                n   := 0
            else
                out := out + array.get(y, i) + " "
        
        while str.length(out) < 9
            out := "‏ " + out + " ‏"
    out

// Define Table
var tbl = table.new(locNsze(tablePos), array.size(titlCol) + 1, matrix.rows(spreadSheet) + 2,
      frame_width  = 1, frame_color  = color.new(tBgCol, 100), 
      border_width = 1, border_color = color.new(tBgCol, 100))

// Cell
cell(col, row, txt, color) =>    
    table.cell(tbl, col, row, txt, 
     text_color = na(color) ? na : txtCol, bgcolor = color, text_size = locNsze(tableSiz))

// Plot Table
if barstate.islast
    table.clear(tbl, 0, 0, array.size(titlCol), matrix.rows(spreadSheet) + 1)
    k = 0, w = 0

    if vrtAdj < 0 
        table.cell(tbl, 0, k, "", height = math.abs(vrtAdj))
        k += 1
    else if vrtAdj > 0 
        table.cell(tbl, 0, matrix.rows(spreadSheet) + 1, "", height = math.abs(vrtAdj))
    
    if hrzAdj < 0
        table.cell(tbl, array.size(titlCol), 0, "", width = math.abs(hrzAdj))
    else if hrzAdj > 0
        table.cell(tbl, w, 0, "", width = math.abs(hrzAdj))
        w += 1

    for i = 0 to array.size(titlCol) - 1
        cell(i + w , k, title(array.get(titlCol, i)), hidTitl ? na :
         (i == 0 and hidsyms) ? na : tBgCol)
    k += 1
        
    for j = 0 to matrix.rows(spreadSheet) - 1
        for i = 0 to matrix.columns(spreadSheet) - 1
            cell(i + w, k, matrix.get(spreadSheet, j, i), matrix.get(spreadSheetClr, j, i))
        k += 1
    
