Market Screener for Momentum indicators
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TintinTrading

//@version=5
//@version=5
indicator('Multiple Indicators Screener', overlay=true)

////////////

// INPUTS //
// {
// SQN
indi0 = input(defval = true, title = "SQN interval", inline = "sqn", group = "SQN")
indi0l = input(defval = 100, title = "", inline = "sqn", group = "SQN")
sqn_superbull  = input.float(1.4, title = "SuperBullish", group = "SQN")
sqn_bull  = input.float(0.7, title = "Bullish", group = "SQN")
sqn_neutral  = input.float(0, title = "Neutral", group = "SQN")
sqn_bear  = input.float(-0.7, title = "Bearish", group = "SQN")
_pos = input.string("Top Right", title="Label Position", options=["Top Left", "Top Center", "Top Right", "Middle Left", "Middle Center", "Middle Right", "Bottom Left", "Bottom Center", "Bottom Right"], group="Layout")

// TSI
// tsi_long_len = input.int(   25, title = "TSI Long Length",   group = "Indicators")
// tsi_shrt_len = input.int(   13, title = "TSI Short Length",  group = "Indicators")
// tsi_ob       = input.float( 0.75, title = "TSI Overbought",    group = 'Indicators')
// tsi_os       = input.float( 0, title = "TSI Oversold",      group = 'Indicators')

//SQUEEZE
sqz_len         = input.int(20, title = "Squeeze Lenght", group = "Squeeze")

// ADX Params
adx_smooth   = input.int(  14, title = "ADX Smoothing",     group = 'ADX')
adx_dilen    = input.int(  14, title = "ADX DI Length",     group = 'ADX')
adx_level    = input.float(20, title = "ADX Level",         group = 'ADX')

// UDV
//sup_atr_len = input.int(   10, "Supertrend ATR Length", group = 'Trend')
//sup_factor  = input.float(3.0, "Supertrend Factor",     group = 'Trend')
indi5 = input(defval = true, title = "Up/Down vol days", inline = "uvd", group = "Up Down Volume")
indi5l = input(defval = 50, title = "", inline = "uvd", group = "Up Down Volume")
input5t = input(defval = 1.1, title = "Treshold" ,group = "Up Down Volume")

// }

/////////////
// SYMBOLS // 
// {
u01 = input.bool(true,  title = "", group = 'Symbols', inline = 's01')
u02 = input.bool(true,  title = "", group = 'Symbols', inline = 's02')
u03 = input.bool(true,  title = "", group = 'Symbols', inline = 's03')
u04 = input.bool(true,  title = "", group = 'Symbols', inline = 's04')
u05 = input.bool(true,  title = "", group = 'Symbols', inline = 's05')
u06 = input.bool(true,  title = "", group = 'Symbols', inline = 's06')
u07 = input.bool(true,  title = "", group = 'Symbols', inline = 's07')
u08 = input.bool(true,  title = "", group = 'Symbols', inline = 's08')
u09 = input.bool(true,  title = "", group = 'Symbols', inline = 's09')
u10 = input.bool(true,  title = "", group = 'Symbols', inline = 's10')
u11 = input.bool(true,  title = "", group = 'Symbols', inline = 's11')
u12 = input.bool(true,  title = "", group = 'Symbols', inline = 's12')
u13 = input.bool(true,  title = "", group = 'Symbols', inline = 's13')
u14 = input.bool(true,  title = "", group = 'Symbols', inline = 's14')
u15 = input.bool(true,  title = "", group = 'Symbols', inline = 's15')
u16 = input.bool(true,  title = "", group = 'Symbols', inline = 's16')
u17 = input.bool(true,  title = "", group = 'Symbols', inline = 's17')
u18 = input.bool(true,  title = "", group = 'Symbols', inline = 's18')
u19 = input.bool(true,  title = "", group = 'Symbols', inline = 's19')
u20 = input.bool(true,  title = "", group = 'Symbols', inline = 's20')
u21 = input.bool(true,  title = "", group = 'Symbols', inline = 's21')
u22 = input.bool(true,  title = "", group = 'Symbols', inline = 's22')
u23 = input.bool(true,  title = "", group = 'Symbols', inline = 's23')
u24 = input.bool(true,  title = "", group = 'Symbols', inline = 's24')
u25 = input.bool(true,  title = "", group = 'Symbols', inline = 's25')
u26 = input.bool(true,  title = "", group = 'Symbols', inline = 's26')
u27 = input.bool(true,  title = "", group = 'Symbols', inline = 's27')
u28 = input.bool(true,  title = "", group = 'Symbols', inline = 's28')
u29 = input.bool(true,  title = "", group = 'Symbols', inline = 's29')
u30 = input.bool(true,  title = "", group = 'Symbols', inline = 's30')
u31 = input.bool(true,  title = "", group = 'Symbols', inline = 's31')
u32 = input.bool(true,  title = "", group = 'Symbols', inline = 's32')
u33 = input.bool(true,  title = "", group = 'Symbols', inline = 's33')
u34 = input.bool(true,  title = "", group = 'Symbols', inline = 's34')
u35 = input.bool(true,  title = "", group = 'Symbols', inline = 's35')
u36 = input.bool(false, title = "", group = 'Symbols', inline = 's36')
u37 = input.bool(false, title = "", group = 'Symbols', inline = 's37')
u38 = input.bool(false, title = "", group = 'Symbols', inline = 's38')
u39 = input.bool(false, title = "", group = 'Symbols', inline = 's39')
u40 = input.bool(false, title = "", group = 'Symbols', inline = 's40')

s01 = input.symbol('SPY',  group = 'Symbols', inline = 's01')
s02 = input.symbol('RSP',  group = 'Symbols', inline = 's02')
s03 = input.symbol('NDQ', group = 'Symbols', inline = 's03')
s04 = input.symbol('NDXE',  group = 'Symbols', inline = 's04')
s05 = input.symbol('QQQ',  group = 'Symbols', inline = 's05')
s06 = input.symbol('QQQE',  group = 'Symbols', inline = 's06')
s07 = input.symbol('XLK',   group = 'Symbols', inline = 's07')
s08 = input.symbol('RYT',  group = 'Symbols', inline = 's08')
s09 = input.symbol('XLRE',  group = 'Symbols', inline = 's09')
s10 = input.symbol('RYE',  group = 'Symbols', inline = 's10')
s11 = input.symbol('XLF',  group = 'Symbols', inline = 's11')
s12 = input.symbol('RYF',  group = 'Symbols', inline = 's12')
s13 = input.symbol('XLI',  group = 'Symbols', inline = 's13')
s14 = input.symbol('RGI',   group = 'Symbols', inline = 's14')
s15 = input.symbol('XLU',   group = 'Symbols', inline = 's15')
s16 = input.symbol('RYU',  group = 'Symbols', inline = 's16')
s17 = input.symbol('XLP',  group = 'Symbols', inline = 's17')
s18 = input.symbol('RHS',  group = 'Symbols', inline = 's18')
s19 = input.symbol('XLV',  group = 'Symbols', inline = 's19')
s20 = input.symbol('RYH',  group = 'Symbols', inline = 's20')
s21 = input.symbol('XLY',  group = 'Symbols', inline = 's21')
s22 = input.symbol('RCD',  group = 'Symbols', inline = 's22')
s23 = input.symbol('XLRE',  group = 'Symbols', inline = 's23')
s24 = input.symbol('EWRE',   group = 'Symbols', inline = 's24')
s25 = input.symbol('XLC', group = 'Symbols', inline = 's25')
s26 = input.symbol('EWCO',  group = 'Symbols', inline = 's26')
s27 = input.symbol('TLT', group = 'Symbols', inline = 's27')
s28 = input.symbol('US05',   group = 'Symbols', inline = 's28')
s29 = input.symbol('US10', group = 'Symbols', inline = 's29')
s30 = input.symbol('US30',   group = 'Symbols', inline = 's30')
s31 = input.symbol('BTCUSDT',  group = 'Symbols', inline = 's31')
s32 = input.symbol('ETHUSDT',  group = 'Symbols', inline = 's32')
s33 = input.symbol('DXY',  group = 'Symbols', inline = 's33')
s34 = input.symbol('AUDJPY',  group = 'Symbols', inline = 's34')
s35 = input.symbol('USOIL',  group = 'Symbols', inline = 's35')
s36 = input.symbol('BOIL', group = 'Symbols', inline = 's36')
s37 = input.symbol('GLC',   group = 'Symbols', inline = 's37')
s38 = input.symbol('SLV',   group = 'Symbols', inline = 's38')
s39 = input.symbol('IOSTBTC',  group = 'Symbols', inline = 's39')
s40 = input.symbol('GRTUSDT',  group = 'Symbols', inline = 's40')
// }
//////////////////

// CALCULATIONS //
// {
// Get only symbol

f_getPosition(_pos) =>
    ret = position.top_left
    if _pos == "Top Center"
        ret := position.top_center
    if _pos == "Top Right"
        ret := position.top_right
    if _pos == "Middle Left"
        ret := position.middle_left
    if _pos == "Middle Center"
        ret := position.middle_center
    if _pos == "Middle Right"
        ret := position.middle_right
    if _pos == "Bottom Left"
        ret := position.bottom_left
    if _pos == "Bottom Center"
        ret := position.bottom_center
    if _pos == "Bottom Right"
        ret := position.bottom_right
    ret



only_symbol(s) => 
    array.get(str.split(s, ":"), 1)


// CHANGE
change_func()=>
    change = ((close - close[1])/close[1])*100
    chage_=math.round(change,2)


// for TSI
double_smooth(src, long, short) =>
	fist_smooth = ta.ema(src, long)
	ta.ema(fist_smooth, short)


squeeze_func () => 
    ma = ta.sma(close, sqz_len)
    devBB = ta.stdev(close, sqz_len)
    devKC = ta.sma(ta.tr, sqz_len)
    upBB = ma + devBB * 2
    lowBB = ma - devBB * 2
    upKCWide = ma + devKC * 2
    lowKCWide = ma - devKC * 2
    upKCNormal = ma + devKC * 1.5
    lowKCNormal = ma - devKC * 1.5
    upKCNarrow = ma + devKC
    lowKCNarrow = ma - devKC
    //sqzOnNormal = lowBB >= lowKCNormal and upBB <= upKCNormal ? 1 : 0  //NORMAL SQUEEZE: RED
    sqzOnNormal = lowBB >= lowKCNormal and upBB <= upKCNormal //NORMAL SQUEEZE: RED
    sqzOnNarrow = lowBB >= lowKCNarrow and upBB <= upKCNarrow  //NARROW SQUEEZE: YELLOW
    sqzOnWide = lowBB >= lowKCWide and upBB <= upKCWide  //WIDE SQUEEZE: ORANGE
    //noSqz = sqzOnWide == false and sqzOffWide == false  //NO SQUEEZE: BLUE
    sqzOffWide = lowBB < lowKCWide and upBB > upKCWide  //FIRED WIDE SQUEEZE: GREEN
    tsi = sqzOnNarrow ? 4 : sqzOnNormal ? 3 : sqzOnWide ? 2 : sqzOffWide ? 1  : 0
    [tsi]




// ADX
dirmov(len) =>
	up   =  ta.change(high)
	down = -ta.change(low)
	
	plusDM  = na(up)   ? na : (up > down and up > 0   ? up   : 0)
	minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
	
	truerange = ta.rma(ta.tr, len)
	
	plus  = fixnan(100 * ta.rma(plusDM, len)  / truerange)
	minus = fixnan(100 * ta.rma(minusDM, len) / truerange)
	[plus, minus]
	
adx_func(dilen, adxlen) =>
	[plus, minus] = dirmov(dilen)
	sum = plus + minus
	adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adxlen)

// SQN
sqn_func() =>
    close_difference = close/close[1]-1
    Stdev = ta.stdev(close_difference,indi0l)
    _sma= ta.sma(close_difference,indi0l)
    rsi=((_sma*math.sqrt(indi0l))/Stdev)
    [rsi]
    
//UDV
udv() =>
    upvol = math.sum(ta.change(close) > 0 ? volume : 0, indi5l)
    downvol = math.sum(ta.change(close) < 0 ? volume : 0, indi5l)
    udv = math.round(upvol/downvol,2)
    sup_dir =udv

screener_func() =>
  
    cl = change_func()
    
    // RSI
    [rsi] = sqn_func()
    
    // TSI
    // pc = ta.change(close)

    // double_smoothed_pc     = double_smooth(pc,           tsi_long_len, tsi_shrt_len)
    // double_smoothed_abs_pc = double_smooth(math.abs(pc), tsi_long_len, tsi_shrt_len)
    
    // tsi = 100 * (double_smoothed_pc / double_smoothed_abs_pc)
    
    [tsi] = squeeze_func()
    // ADX 
    adx = adx_func(adx_dilen, adx_smooth)
    
    // Supertrend
//    [sup_value, sup_dir] = ta.supertrend(sup_factor, sup_atr_len)
    sup_dir = udv()
    
    [cl, rsi, tsi, adx, sup_dir]

// Security call
[cl01, rsi01, tsi01, adx01, sup01] = request.security(s01, timeframe.period, screener_func())
[cl02, rsi02, tsi02, adx02, sup02] = request.security(s02, timeframe.period, screener_func())
[cl03, rsi03, tsi03, adx03, sup03] = request.security(s03, timeframe.period, screener_func())
[cl04, rsi04, tsi04, adx04, sup04] = request.security(s04, timeframe.period, screener_func())
[cl05, rsi05, tsi05, adx05, sup05] = request.security(s05, timeframe.period, screener_func())
[cl06, rsi06, tsi06, adx06, sup06] = request.security(s06, timeframe.period, screener_func())
[cl07, rsi07, tsi07, adx07, sup07] = request.security(s07, timeframe.period, screener_func())
[cl08, rsi08, tsi08, adx08, sup08] = request.security(s08, timeframe.period, screener_func())
[cl09, rsi09, tsi09, adx09, sup09] = request.security(s09, timeframe.period, screener_func())
[cl10, rsi10, tsi10, adx10, sup10] = request.security(s10, timeframe.period, screener_func())
[cl11, rsi11, tsi11, adx11, sup11] = request.security(s11, timeframe.period, screener_func())
[cl12, rsi12, tsi12, adx12, sup12] = request.security(s12, timeframe.period, screener_func())
[cl13, rsi13, tsi13, adx13, sup13] = request.security(s13, timeframe.period, screener_func())
[cl14, rsi14, tsi14, adx14, sup14] = request.security(s14, timeframe.period, screener_func())
[cl15, rsi15, tsi15, adx15, sup15] = request.security(s15, timeframe.period, screener_func())
[cl16, rsi16, tsi16, adx16, sup16] = request.security(s16, timeframe.period, screener_func())
[cl17, rsi17, tsi17, adx17, sup17] = request.security(s17, timeframe.period, screener_func())
[cl18, rsi18, tsi18, adx18, sup18] = request.security(s18, timeframe.period, screener_func())
[cl19, rsi19, tsi19, adx19, sup19] = request.security(s19, timeframe.period, screener_func())
[cl20, rsi20, tsi20, adx20, sup20] = request.security(s20, timeframe.period, screener_func())
[cl21, rsi21, tsi21, adx21, sup21] = request.security(s21, timeframe.period, screener_func())
[cl22, rsi22, tsi22, adx22, sup22] = request.security(s22, timeframe.period, screener_func())
[cl23, rsi23, tsi23, adx23, sup23] = request.security(s23, timeframe.period, screener_func())
[cl24, rsi24, tsi24, adx24, sup24] = request.security(s24, timeframe.period, screener_func())
[cl25, rsi25, tsi25, adx25, sup25] = request.security(s25, timeframe.period, screener_func())
[cl26, rsi26, tsi26, adx26, sup26] = request.security(s26, timeframe.period, screener_func())
[cl27, rsi27, tsi27, adx27, sup27] = request.security(s27, timeframe.period, screener_func())
[cl28, rsi28, tsi28, adx28, sup28] = request.security(s28, timeframe.period, screener_func())
[cl29, rsi29, tsi29, adx29, sup29] = request.security(s29, timeframe.period, screener_func())
[cl30, rsi30, tsi30, adx30, sup30] = request.security(s30, timeframe.period, screener_func())
[cl31, rsi31, tsi31, adx31, sup31] = request.security(s31, timeframe.period, screener_func())
[cl32, rsi32, tsi32, adx32, sup32] = request.security(s32, timeframe.period, screener_func())
[cl33, rsi33, tsi33, adx33, sup33] = request.security(s33, timeframe.period, screener_func())
[cl34, rsi34, tsi34, adx34, sup34] = request.security(s34, timeframe.period, screener_func())
[cl35, rsi35, tsi35, adx35, sup35] = request.security(s35, timeframe.period, screener_func())
[cl36, rsi36, tsi36, adx36, sup36] = request.security(s36, timeframe.period, screener_func())
[cl37, rsi37, tsi37, adx37, sup37] = request.security(s37, timeframe.period, screener_func())
[cl38, rsi38, tsi38, adx38, sup38] = request.security(s38, timeframe.period, screener_func())
[cl39, rsi39, tsi39, adx39, sup39] = request.security(s39, timeframe.period, screener_func())
[cl40, rsi40, tsi40, adx40, sup40] = request.security(s40, timeframe.period, screener_func())
// }
////////////

// ARRAYS //
// {
s_arr   = array.new_string(0)
u_arr   = array.new_bool(0)
cl_arr  = array.new_float(0)
rsi_arr = array.new_float(0)
tsi_arr = array.new_float(0)
adx_arr = array.new_float(0)
sup_arr = array.new_float(0)

// Add Symbols 
array.push(s_arr, only_symbol(s01))
array.push(s_arr, only_symbol(s02))
array.push(s_arr, only_symbol(s03))
array.push(s_arr, only_symbol(s04))
array.push(s_arr, only_symbol(s05))
array.push(s_arr, only_symbol(s06))
array.push(s_arr, only_symbol(s07))
array.push(s_arr, only_symbol(s08))
array.push(s_arr, only_symbol(s09))
array.push(s_arr, only_symbol(s10))
array.push(s_arr, only_symbol(s11))
array.push(s_arr, only_symbol(s12))
array.push(s_arr, only_symbol(s13))
array.push(s_arr, only_symbol(s14))
array.push(s_arr, only_symbol(s15))
array.push(s_arr, only_symbol(s16))
array.push(s_arr, only_symbol(s17))
array.push(s_arr, only_symbol(s18))
array.push(s_arr, only_symbol(s19))
array.push(s_arr, only_symbol(s20))
array.push(s_arr, only_symbol(s21))
array.push(s_arr, only_symbol(s22))
array.push(s_arr, only_symbol(s23))
array.push(s_arr, only_symbol(s24))
array.push(s_arr, only_symbol(s25))
array.push(s_arr, only_symbol(s26))
array.push(s_arr, only_symbol(s27))
array.push(s_arr, only_symbol(s28))
array.push(s_arr, only_symbol(s29))
array.push(s_arr, only_symbol(s30))
array.push(s_arr, only_symbol(s31))
array.push(s_arr, only_symbol(s32))
array.push(s_arr, only_symbol(s33))
array.push(s_arr, only_symbol(s34))
array.push(s_arr, only_symbol(s35))
array.push(s_arr, only_symbol(s36))
array.push(s_arr, only_symbol(s37))
array.push(s_arr, only_symbol(s38))
array.push(s_arr, only_symbol(s39))
array.push(s_arr, only_symbol(s40))
// }
///////////

// FLAGS //
// {
array.push(u_arr, u01)
array.push(u_arr, u02)
array.push(u_arr, u03)
array.push(u_arr, u04)
array.push(u_arr, u05)
array.push(u_arr, u06)
array.push(u_arr, u07)
array.push(u_arr, u08)
array.push(u_arr, u09)
array.push(u_arr, u10)
array.push(u_arr, u11)
array.push(u_arr, u12)
array.push(u_arr, u13)
array.push(u_arr, u14)
array.push(u_arr, u15)
array.push(u_arr, u16)
array.push(u_arr, u17)
array.push(u_arr, u18)
array.push(u_arr, u19)
array.push(u_arr, u20)
array.push(u_arr, u21)
array.push(u_arr, u22)
array.push(u_arr, u23)
array.push(u_arr, u24)
array.push(u_arr, u25)
array.push(u_arr, u26)
array.push(u_arr, u27)
array.push(u_arr, u28)
array.push(u_arr, u29)
array.push(u_arr, u30)
array.push(u_arr, u31)
array.push(u_arr, u32)
array.push(u_arr, u33)
array.push(u_arr, u34)
array.push(u_arr, u35)
array.push(u_arr, u36)
array.push(u_arr, u37)
array.push(u_arr, u38)
array.push(u_arr, u39)
array.push(u_arr, u40)
// }

///////////
// CLOSE //
// {
array.push(cl_arr, cl01)
array.push(cl_arr, cl02)
array.push(cl_arr, cl03)
array.push(cl_arr, cl04)
array.push(cl_arr, cl05)
array.push(cl_arr, cl06)
array.push(cl_arr, cl07)
array.push(cl_arr, cl08)
array.push(cl_arr, cl09)
array.push(cl_arr, cl10)
array.push(cl_arr, cl11)
array.push(cl_arr, cl12)
array.push(cl_arr, cl13)
array.push(cl_arr, cl14)
array.push(cl_arr, cl15)
array.push(cl_arr, cl16)
array.push(cl_arr, cl17)
array.push(cl_arr, cl18)
array.push(cl_arr, cl19)
array.push(cl_arr, cl20)
array.push(cl_arr, cl21)
array.push(cl_arr, cl22)
array.push(cl_arr, cl23)
array.push(cl_arr, cl24)
array.push(cl_arr, cl25)
array.push(cl_arr, cl26)
array.push(cl_arr, cl27)
array.push(cl_arr, cl28)
array.push(cl_arr, cl29)
array.push(cl_arr, cl30)
array.push(cl_arr, cl31)
array.push(cl_arr, cl32)
array.push(cl_arr, cl33)
array.push(cl_arr, cl34)
array.push(cl_arr, cl35)
array.push(cl_arr, cl36)
array.push(cl_arr, cl37)
array.push(cl_arr, cl38)
array.push(cl_arr, cl39)
array.push(cl_arr, cl40)
// }
/////////

// RSI //
// {
array.push(rsi_arr, rsi01)
array.push(rsi_arr, rsi02)
array.push(rsi_arr, rsi03)
array.push(rsi_arr, rsi04)
array.push(rsi_arr, rsi05)
array.push(rsi_arr, rsi06)
array.push(rsi_arr, rsi07)
array.push(rsi_arr, rsi08)
array.push(rsi_arr, rsi09)
array.push(rsi_arr, rsi10)
array.push(rsi_arr, rsi11)
array.push(rsi_arr, rsi12)
array.push(rsi_arr, rsi13)
array.push(rsi_arr, rsi14)
array.push(rsi_arr, rsi15)
array.push(rsi_arr, rsi16)
array.push(rsi_arr, rsi17)
array.push(rsi_arr, rsi18)
array.push(rsi_arr, rsi19)
array.push(rsi_arr, rsi20)
array.push(rsi_arr, rsi21)
array.push(rsi_arr, rsi22)
array.push(rsi_arr, rsi23)
array.push(rsi_arr, rsi24)
array.push(rsi_arr, rsi25)
array.push(rsi_arr, rsi26)
array.push(rsi_arr, rsi27)
array.push(rsi_arr, rsi28)
array.push(rsi_arr, rsi29)
array.push(rsi_arr, rsi30)
array.push(rsi_arr, rsi31)
array.push(rsi_arr, rsi32)
array.push(rsi_arr, rsi33)
array.push(rsi_arr, rsi34)
array.push(rsi_arr, rsi35)
array.push(rsi_arr, rsi36)
array.push(rsi_arr, rsi37)
array.push(rsi_arr, rsi38)
array.push(rsi_arr, rsi39)
array.push(rsi_arr, rsi40)
// }
/////////

// TSI //
// {
array.push(tsi_arr, tsi01)
array.push(tsi_arr, tsi02)
array.push(tsi_arr, tsi03)
array.push(tsi_arr, tsi04)
array.push(tsi_arr, tsi05)
array.push(tsi_arr, tsi06)
array.push(tsi_arr, tsi07)
array.push(tsi_arr, tsi08)
array.push(tsi_arr, tsi09)
array.push(tsi_arr, tsi10)
array.push(tsi_arr, tsi11)
array.push(tsi_arr, tsi12)
array.push(tsi_arr, tsi13)
array.push(tsi_arr, tsi14)
array.push(tsi_arr, tsi15)
array.push(tsi_arr, tsi16)
array.push(tsi_arr, tsi17)
array.push(tsi_arr, tsi18)
array.push(tsi_arr, tsi19)
array.push(tsi_arr, tsi20)
array.push(tsi_arr, tsi21)
array.push(tsi_arr, tsi22)
array.push(tsi_arr, tsi23)
array.push(tsi_arr, tsi24)
array.push(tsi_arr, tsi25)
array.push(tsi_arr, tsi26)
array.push(tsi_arr, tsi27)
array.push(tsi_arr, tsi28)
array.push(tsi_arr, tsi29)
array.push(tsi_arr, tsi30)
array.push(tsi_arr, tsi31)
array.push(tsi_arr, tsi32)
array.push(tsi_arr, tsi33)
array.push(tsi_arr, tsi34)
array.push(tsi_arr, tsi35)
array.push(tsi_arr, tsi36)
array.push(tsi_arr, tsi37)
array.push(tsi_arr, tsi38)
array.push(tsi_arr, tsi39)
array.push(tsi_arr, tsi40)
// }
/////////

// ADX //
// {
array.push(adx_arr, adx01)
array.push(adx_arr, adx02)
array.push(adx_arr, adx03)
array.push(adx_arr, adx04)
array.push(adx_arr, adx05)
array.push(adx_arr, adx06)
array.push(adx_arr, adx07)
array.push(adx_arr, adx08)
array.push(adx_arr, adx09)
array.push(adx_arr, adx10)
array.push(adx_arr, adx11)
array.push(adx_arr, adx12)
array.push(adx_arr, adx13)
array.push(adx_arr, adx14)
array.push(adx_arr, adx15)
array.push(adx_arr, adx16)
array.push(adx_arr, adx17)
array.push(adx_arr, adx18)
array.push(adx_arr, adx19)
array.push(adx_arr, adx20)
array.push(adx_arr, adx21)
array.push(adx_arr, adx22)
array.push(adx_arr, adx23)
array.push(adx_arr, adx24)
array.push(adx_arr, adx25)
array.push(adx_arr, adx26)
array.push(adx_arr, adx27)
array.push(adx_arr, adx28)
array.push(adx_arr, adx29)
array.push(adx_arr, adx30)
array.push(adx_arr, adx31)
array.push(adx_arr, adx32)
array.push(adx_arr, adx33)
array.push(adx_arr, adx34)
array.push(adx_arr, adx35)
array.push(adx_arr, adx36)
array.push(adx_arr, adx37)
array.push(adx_arr, adx38)
array.push(adx_arr, adx39)
array.push(adx_arr, adx40)
// }
////////////////

// SUPERTREND //
// {
array.push(sup_arr, sup01)
array.push(sup_arr, sup02)
array.push(sup_arr, sup03)
array.push(sup_arr, sup04)
array.push(sup_arr, sup05)
array.push(sup_arr, sup06)
array.push(sup_arr, sup07)
array.push(sup_arr, sup08)
array.push(sup_arr, sup09)
array.push(sup_arr, sup10)
array.push(sup_arr, sup11)
array.push(sup_arr, sup12)
array.push(sup_arr, sup13)
array.push(sup_arr, sup14)
array.push(sup_arr, sup15)
array.push(sup_arr, sup16)
array.push(sup_arr, sup17)
array.push(sup_arr, sup18)
array.push(sup_arr, sup19)
array.push(sup_arr, sup20)
array.push(sup_arr, sup21)
array.push(sup_arr, sup22)
array.push(sup_arr, sup23)
array.push(sup_arr, sup24)
array.push(sup_arr, sup25)
array.push(sup_arr, sup26)
array.push(sup_arr, sup27)
array.push(sup_arr, sup28)
array.push(sup_arr, sup29)
array.push(sup_arr, sup30)
array.push(sup_arr, sup31)
array.push(sup_arr, sup32)
array.push(sup_arr, sup33)
array.push(sup_arr, sup34)
array.push(sup_arr, sup35)
array.push(sup_arr, sup36)
array.push(sup_arr, sup37)
array.push(sup_arr, sup38)
array.push(sup_arr, sup39)
array.push(sup_arr, sup40)
// }
///////////

// PLOTS //
// {
var tbl = table.new(f_getPosition(_pos), 6, 41, frame_color=#151715, frame_width=1, border_width=2, border_color=color.new(color.white, 100))

if barstate.islast

    table.cell(tbl, 0, 0, 'Symbol',     text_halign = text.align_center, bgcolor = color.black, text_color = color.white, text_size = size.small)
    table.cell(tbl, 1, 0, 'Change',      text_halign = text.align_center, bgcolor = color.black, text_color = color.white, text_size = size.small)
    table.cell(tbl, 2, 0, 'SQN'+"\n"+"100",        text_halign = text.align_center, bgcolor = color.black, text_color = color.white, text_size = size.small)
    table.cell(tbl, 3, 0, 'SQZ'+"\n"+"Pro",        text_halign = text.align_center, bgcolor = color.black, text_color = color.white, text_size = size.small)
    table.cell(tbl, 4, 0, 'ADX',        text_halign = text.align_center, bgcolor = color.black, text_color = color.white, text_size = size.small)
    table.cell(tbl, 5, 0, 'UDV', text_halign = text.align_center, bgcolor = color.black, text_color = color.white, text_size = size.small)

    for i = 0 to 39
        if array.get(u_arr, i)
            cl_col   = array.get(cl_arr, i) > 0                                                         ? #04D204 : #FF0000
            rsi_col  = array.get(rsi_arr, i) > sqn_superbull                                            ? #04D204 :
                       array.get(rsi_arr, i) > sqn_bull and  array.get(rsi_arr, i) < sqn_superbull      ? #006400 : 
                       array.get(rsi_arr, i) > sqn_neutral and  array.get(rsi_arr, i) < sqn_bull        ? #1EBAB5 :
                       array.get(rsi_arr, i) > sqn_bear and  array.get(rsi_arr, i) < sqn_neutral        ? #800000 :
                       array.get(rsi_arr, i) < sqn_bear                                                 ? #FF0000 : #aaaaaa 
            tsi_col  = array.get(tsi_arr, i) == 4                                                    ? color.gray   :
                       array.get(tsi_arr, i) == 3                                                    ? color.gray :
                       array.get(tsi_arr, i) == 2                                                    ? color.gray :
                       array.get(tsi_arr, i) == 1                                                    ? color.gray : #aaaaaa  
            adx_col  = array.get(adx_arr, i) > adx_level and array.get(rsi_arr, i) > sqn_bull       ? #04D204 :
                       array.get(adx_arr, i) > adx_level and array.get(rsi_arr, i) < sqn_neutral    ? #FF0000 : #aaaaaa 
            tsi_text = array.get(tsi_arr, i) == 4                                                    ? "🟠" :
                       array.get(tsi_arr, i) == 3                                                    ? "🔴" :
                       array.get(tsi_arr, i) == 2                                                    ? "⚪" :
                       array.get(tsi_arr, i) == 1                                                    ? " " : "N/A"  
            sqn_text = array.get(rsi_arr, i) > sqn_superbull  ? "SB" :
                       array.get(rsi_arr, i) > sqn_bull and  array.get(rsi_arr, i) < sqn_superbull  ? "B" : 
                       array.get(rsi_arr, i) > sqn_neutral and  array.get(rsi_arr, i) < sqn_bull  ? "N" :
                       array.get(rsi_arr, i) > sqn_bear and  array.get(rsi_arr, i) < sqn_neutral  ? "Br" :
                       array.get(rsi_arr, i) < sqn_bear ? "SBr" : "NA" 
            //sup_text = array.get(sup_arr, i) > 0 ? "Down"      : "Up"
            sup_col  = array.get(sup_arr, i) > input5t ? #04D204 :
                       array.get(sup_arr, i) < input5t ? #FF0000 : color.gray
            
            table.cell(tbl, 0, i + 1, array.get(s_arr, i),                                 text_halign = text.align_left,   bgcolor = color.black, text_color = color.white, text_size = size.small)
            table.cell(tbl, 1, i + 1, str.tostring(array.get(cl_arr, i))+"%",                  text_halign = text.align_center, bgcolor = cl_col,    text_color = color.white, text_size = size.small)
            table.cell(tbl, 2, i + 1, sqn_text,                                            text_halign = text.align_center, bgcolor = rsi_col,    text_color = color.white, text_size = size.small)
            table.cell(tbl, 3, i + 1, tsi_text,                                            text_halign = text.align_center, bgcolor = tsi_col,    text_color = color.white, text_size = size.small)
            table.cell(tbl, 4, i + 1, str.tostring(array.get(adx_arr, i), "#.##"),         text_halign = text.align_center, bgcolor = adx_col   , text_color = color.white, text_size = size.small)
            table.cell(tbl, 5, i + 1, str.tostring(array.get(sup_arr, i), "#.##"),         text_halign = text.align_center, bgcolor = sup_col,    text_color = color.white, text_size = size.small)
// }



