How To Identify Argument Type Of Number Using Overloads
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © allanster

//@version=5
indicator(title = "How To Identify Argument Type Of Number Using Overloads", shorttitle = 'argument type', overlay = true, precision = 16)

// Example overload functions accept loading of _value for types float, int, or string, then positively
// identifies the actual argument type of that specific loaded _value.

// === Function ===
f_idType(int _value) => // input: type int | output: returns string of 'Type: Int'
    is_Intgr  = _value ? 'Type: int' : string(na)                 // is definitely an integer

f_idType(float _value) => // input: type float | output: returns string of 'Type: Float'
    is_Float  = _value ? 'Type: float' : string(na)               // is definitely a float

f_idType(string _value) => // input: type string | output: returns string of input 'Type: String (info)' 
    is_Numbr  = not na(str.tonumber(_value))                      // is number
    is_Float  = is_Numbr and not na(str.pos(_value, '.'))         // is float
    is_Intgr  = is_Numbr and not is_Float                         // is integer
    identify  =
     is_Intgr ? 'Type: string (Integer)' :
     is_Float ? 'Type: string (Float)'   : 'Type: string'         // return string of argument type

// === EXAMPLE VALUES ===
float  cnt0 =  0.123456789                                        // form const  type float
int    cnt1 =  12345678901                                        // form const  type integer
string cnt2 = '0.123456789'                                       // form const  type string
string cnt3 = '12345678901'                                       // form const  type string
string cnt4 = 'hello world'                                       // form const  type string

float  inp0 = input( 0.123456789,  'Float')                       // form input  type float
int    inp1 = input( 12345678901,  'Integer')                     // form input  type integer
string inp2 = input('0.123456789', 'String')                      // form input  type string
string inp3 = input('12345678901', 'String')                      // form input  type string
string inp4 = input('hello world', 'String')                      // form input  type string

float  smp0 = syminfo.mintick                                     // form simple type float
int    smp1 = timeframe.multiplier                                // form simple type integer
string smp2 = timeframe.period                                    // form simple type string

float  ser0 = close > open ? cnt0 : cnt0                          // form series type float
int    ser1 = close > open ? cnt1 : cnt1                          // form series type integer
string ser2 = close > open ? cnt2 : cnt2                          // form series type string
string ser3 = close > open ? cnt3 : cnt3                          // form series type string
string ser4 = close > open ? cnt4 : cnt4                          // form series type string

// === EXAMPLE OUTPUT ===
C_(_str, _column, _row, _t) => // single cell of string _str of number _column of number _row of table _t
    table.cell(_t, _column, _row, _str,
     text_color = #ffffff, text_halign = text.align_center)

R_(_t, _row, _strC0, _strC1, _strC2) => // single row of table _t of number _row of string columns _strCn
    C_(_strC0, 0, _row, _t), C_(_strC1, 1, _row, _t), C_(_strC2, 2, _row, _t)

if barstate.islast
    var T = table.new(position.middle_right, 3, 19, bgcolor = color.new(#3f3f3f, 0),
     border_color = #bfbfbf, border_width = 1, frame_color = #7f7f7f, frame_width = 2)
    
    R_(T,  0, 'FORM  TYPE',   'LOADED VALUE',                  'f_idType(_value)')

    R_(T,  1, 'const float',  '0.123456789',                   str.tostring(f_idType(cnt0)))
    R_(T,  2, 'const int',    '12345678901',                   str.tostring(f_idType(cnt1)))
    R_(T,  3, 'const strng',  '"0.123456789"',                 str.tostring(f_idType(cnt2)))
    R_(T,  4, 'const strng',  '"12345678901"',                 str.tostring(f_idType(cnt3)))
    R_(T,  5, 'const strng',  '"hello world"',                 str.tostring(f_idType(cnt4)))
    
    R_(T,  6, 'input float',  str.tostring(inp0),              str.tostring(f_idType(inp0)))
    R_(T,  7, 'input int',    str.tostring(inp1),              str.tostring(f_idType(inp1)))
    R_(T,  8, 'input strng',  '"' + str.tostring(inp2) + '"',  str.tostring(f_idType(inp2)))
    R_(T,  9, 'input strng',  '"' + str.tostring(inp3) + '"',  str.tostring(f_idType(inp3)))
    R_(T, 10, 'input strng',  '"' + str.tostring(inp4) + '"',  str.tostring(f_idType(inp4)))

    R_(T, 11, 'simple float', 'syminfo.mintick',               str.tostring(f_idType(smp0)))
    R_(T, 12, 'simple int',   'timeframe.multiplier',          str.tostring(f_idType(smp1)))
    R_(T, 13, 'simple strng', 'timeframe.period',              str.tostring(f_idType(smp2)))

    R_(T, 14, 'series float', '0.123456789',                   str.tostring(f_idType(ser0)))
    R_(T, 15, 'series int',   '12345678901',                   str.tostring(f_idType(ser1)))
    R_(T, 16, 'series strng', '"0.123456789"',                 str.tostring(f_idType(ser2)))
    R_(T, 17, 'series strng', '"12345678901"',                 str.tostring(f_idType(ser3)))
    R_(T, 18, 'series strng', '"hello world"',                 str.tostring(f_idType(ser4)))