Forex & Stock Daily WatchList And Screener [M]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Milvetti

//@version=5
indicator("Forex & Stock Daily WatchList And Screener [M]",overlay = true)




gI = "Indices"
openIndices = input(true,"Show Indices Table",inline = "Ind",group = gI)
indPos = input.string("Top Right","",["Top Left","Top Center","Top Right","Middle Left","Middle Center","Middle Right","Bottom Left","Bottom Center","Bottom Right"],inline = "Ind",group = gI)



a01 = input.bool(true,  title = "", group = gI, inline = 'i01')
a02 = input.bool(true,  title = "", group = gI, inline = 'i02')
a03 = input.bool(true,  title = "", group = gI, inline = 'i03')
a04 = input.bool(true,  title = "", group = gI, inline = 'i04')
a05 = input.bool(true,  title = "", group = gI, inline = 'i05')
a06 = input.bool(true,  title = "", group = gI, inline = 'i06')
a07 = input.bool(true,  title = "", group = gI, inline = 'i07')
a08 = input.bool(true,  title = "", group = gI, inline = 'i08')
a09 = input.bool(true,  title = "", group = gI, inline = 'i09')
a10 = input.bool(true,  title = "", group = gI, inline = 'i10')
a11 = input.bool(true,  title = "", group = gI, inline = 'i11')
a12 = input.bool(true,  title = "", group = gI, inline = 'i12')
a13 = input.bool(true,  title = "", group = gI, inline = 'i13')
a14 = input.bool(true,  title = "", group = gI, inline = 'i14')


i01 = input.symbol('DXY', "",group = gI, inline = 'i01')
i02 = input.symbol('VIX', "",group = gI, inline = 'i02')
i03 = input.symbol('US05Y/US10Y', "",group = gI, inline = 'i03')
i04 = input.symbol('SP500',"",  group = gI, inline = 'i04')
i05 = input.symbol('DJI', "",group = gI, inline = 'i05')
i06 = input.symbol('NASDAQ', "",  group = gI, inline = 'i06')
i07 = input.symbol('BDI',"",  group = gI, inline = 'i07')
i08 = input.symbol('FTSE', "",   group = gI, inline = 'i08')
i09 = input.symbol('Nikkei', "", group = gI, inline = 'i09')
i10 = input.symbol('FESX1!', "", group = gI, inline = 'i10')
i11 = input.symbol('hsi', "", group = gI, inline = 'i11')
i12 = input.symbol('brent', "",  group = gI, inline = 'i12')
i13 = input.symbol('wti', "",  group = gI, inline = 'i13')
i14 = input.symbol('XAUXAG', "", group = gI, inline = 'i14')



gS = 'Symbols'
openSymbols = input(true,"Show Fx Table",inline = "Sym",group = gS)
symPos = input.string("Bottom Right","",["Top Left","Top Center","Top Right","Middle Left","Middle Center","Middle Right","Bottom Left","Bottom Center","Bottom Right"],inline = "Sym",group = gS)


u01 = input.bool(true,  title = "", group = gS, inline = 's01')
u02 = input.bool(true,  title = "", group = gS, inline = 's02')
u03 = input.bool(true,  title = "", group = gS, inline = 's03')
u04 = input.bool(true,  title = "", group = gS, inline = 's04')
u05 = input.bool(true,  title = "", group = gS, inline = 's05')
u06 = input.bool(true,  title = "", group = gS, inline = 's06')
u07 = input.bool(true,  title = "", group = gS, inline = 's07')
u08 = input.bool(false,  title = "", group = gS, inline = 's08')
u09 = input.bool(true,  title = "", group = gS, inline = 's09')
u10 = input.bool(true,  title = "", group = gS, inline = 's10')
u11 = input.bool(false,  title = "", group = gS, inline = 's11')
u12 = input.bool(true,  title = "", group = gS, inline = 's12')
u13 = input.bool(false,  title = "", group = gS, inline = 's13')
u14 = input.bool(false,  title = "", group = gS, inline = 's14')
u15 = input.bool(false,  title = "", group = gS, inline = 's15')
u16 = input.bool(false,  title = "", group = gS, inline = 's16')
u17 = input.bool(true,  title = "", group = gS, inline = 's17')
u18 = input.bool(true,  title = "", group = gS, inline = 's18')
u19 = input.bool(true,  title = "", group = gS, inline = 's19')
u20 = input.bool(false,  title = "", group = gS, inline = 's20')


s01 = input.symbol('EURUSD', "",group = gS, inline = 's01')
s02 = input.symbol('USDJPY', "",group = gS, inline = 's02')
s03 = input.symbol('GBPUSD', "",group = gS, inline = 's03')
s04 = input.symbol('USDCHF',"",  group = gS, inline = 's04')
s05 = input.symbol('AUDUSD', "",group = gS, inline = 's05')
s06 = input.symbol('USDCAD', "",  group = gS, inline = 's06')
s07 = input.symbol('NZDUSD',"",  group = gS, inline = 's07')
s08 = input.symbol('EURJPY', "",   group = gS, inline = 's08')
s09 = input.symbol('EURGBP', "", group = gS, inline = 's09')
s10 = input.symbol('GBPJPY', "", group = gS, inline = 's10')
s11 = input.symbol('EURAUD', "", group = gS, inline = 's11')
s12 = input.symbol('AUDJPY', "",  group = gS, inline = 's12')
s13 = input.symbol('EURCAD', "",  group = gS, inline = 's13')
s14 = input.symbol('USDSGD', "", group = gS, inline = 's14')
s15 = input.symbol('USDHKD', "",group = gS, inline = 's15')
s16 = input.symbol('EURNZD', "", group = gS, inline = 's16')
s17 = input.symbol('META', "",  group = gS, inline = 's17')
s18 = input.symbol('GOOGL', "",group = gS, inline = 's18')
s19 = input.symbol('MSFT', "",group = gS, inline = 's19')
s20 = input.symbol('BABA', "",group = gS, inline = 's20')



getDataI()=>
    prePrice = close-ta.change(close)
    change =   ta.change(close)/prePrice*100
    trend = close>ta.sma(close,50) ? "Up" : "Down"
    stoch = math.round(ta.stoch(close,high,low,30),2)
    price = str.tostring(close,format.mintick)
    [price,change,trend,stoch]



StochSrc = input.source(close,"Source",inline="Stoch",group = "Stochastic")
stochLen = input.int(30,"Length",inline="Stoch",group = "Stochastic")



rsiSrc = input.source(close,"Source",inline="RSI",group = "RSI")
rsiLen = input.int(14,"Length",inline="RSI",group = "RSI")


movSrc = input.source(close,"Source",inline="MOV",group = "Trend(Mov)")
movLen = input.int(50,"Length",inline="MOV",group = "Trend(Mov)")


macdSrc = input.source(close,"Source",group = "MACD")
macdFlen = input.int(12,"Fast Length",group = "MACD")
macdSlen = input.int(26,"Slow Length",group = "MACD")
macdSmooth = input.int(9,"Signal Smoothing",group = "MACD")


getMacd()=>
    [macd,sig,hist] = ta.macd(macdSrc,macdFlen,macdSlen,macdSmooth)
    sigText = hist>=0 ? (hist[1] < hist ? "Strong\nBullish" : "Bullish") : (hist[1] < hist ? "Strong\nBearish" : "Bearish")
    sigText


getDataS()=>
    price = str.tostring(close,format.mintick)
    vol = str.tostring(volume,format.volume)

    prePrice = close-ta.change(close)
    change =   ta.change(close)/prePrice*100

    trend = close>ta.sma(movSrc,movLen) ? "Up" : "Down"
    macdText = getMacd()
    rsi = math.round(ta.rsi(rsiSrc,rsiLen),2)
    stoch = math.round(ta.stoch(StochSrc,high,low,stochLen),2)
    
    [price,vol,change,trend,stoch,rsi,macdText]

getPos(x)=>
    pos = switch x
        "Top Right" => position.top_right
        "Top Center" => position.top_center
        "Top Left" => position.top_left
        "Middle Right" => position.middle_right
        "Middle Center" => position.middle_center
        "Middle Left" => position.middle_left
        "Bottom Right" => position.bottom_right
        "Bottom Center" => position.bottom_center
        "Bottom Left" => position.bottom_left
    pos



getSize(x)=>
    oPut = switch x
        "Tiny" => size.tiny
        "Small" => size.small
        "Medium" => size.normal
        "Large" => size.large
        "Huge" => size.huge
        "Auto" => size.auto
    oPut



[prI1,chI1,trendI1,stochI1] = request.security(i01,"1D",getDataI(),lookahead = barmerge.lookahead_on)
[prI2,chI2, trendI2, stochI2] = request.security(i02, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI3,chI3, trendI3, stochI3] = request.security(i03, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI4,chI4, trendI4, stochI4] = request.security(i04, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI5,chI5, trendI5, stochI5] = request.security(i05, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI6,chI6, trendI6, stochI6] = request.security(i06, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI7,chI7, trendI7, stochI7] = request.security(i07, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI8,chI8, trendI8, stochI8] = request.security(i08, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI9,chI9, trendI9, stochI9] = request.security(i09, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI10,chI10, trendI10, stochI10] = request.security(i10, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI11,chI11, trendI11, stochI11] = request.security(i11, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI12,chI12, trendI12, stochI12] = request.security(i12, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI13,chI13, trendI13, stochI13] = request.security(i13, "1D", getDataI(), lookahead=barmerge.lookahead_on)
[prI14,chI14, trendI14, stochI14] = request.security(i14, "1D", getDataI(), lookahead=barmerge.lookahead_on)

[prS1, volS1, chS1, trendS1, stochS1, rsiS1, macdS1] = request.security(s01, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS2, volS2, chS2, trendS2, stochS2, rsiS2, macdS2] = request.security(s02, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS3, volS3, chS3, trendS3, stochS3, rsiS3, macdS3] = request.security(s03, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS4, volS4, chS4, trendS4, stochS4, rsiS4, macdS4] = request.security(s04, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS5, volS5, chS5, trendS5, stochS5, rsiS5, macdS5] = request.security(s05, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS6, volS6, chS6, trendS6, stochS6, rsiS6, macdS6] = request.security(s06, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS7, volS7, chS7, trendS7, stochS7, rsiS7, macdS7] = request.security(s07, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS8, volS8, chS8, trendS8, stochS8, rsiS8, macdS8] = request.security(s08, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS9, volS9, chS9, trendS9, stochS9, rsiS9, macdS9] = request.security(s09, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS10, volS10, chS10, trendS10, stochS10, rsiS10, macdS10] = request.security(s10, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS11, volS11, chS11, trendS11, stochS11, rsiS11, macdS11] = request.security(s11, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS12, volS12, chS12, trendS12, stochS12, rsiS12, macdS12] = request.security(s12, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS13, volS13, chS13, trendS13, stochS13, rsiS13, macdS13] = request.security(s13, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS14, volS14, chS14, trendS14, stochS14, rsiS14, macdS14] = request.security(s14, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS15, volS15, chS15, trendS15, stochS15, rsiS15, macdS15] = request.security(s15, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS16, volS16, chS16, trendS16, stochS16, rsiS16, macdS16] = request.security(s16, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS17, volS17, chS17, trendS17, stochS17, rsiS17, macdS17] = request.security(s17, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS18, volS18, chS18, trendS18, stochS18, rsiS18, macdS18] = request.security(s18, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS19, volS19, chS19, trendS19, stochS19, rsiS19, macdS19] = request.security(s19, "1D", getDataS(), lookahead = barmerge.lookahead_on)
[prS20, volS20, chS20, trendS20, stochS20, rsiS20, macdS20] = request.security(s20, "1D", getDataS(), lookahead = barmerge.lookahead_on)

var checkIndArray = array.new_bool()
priceIndArray = array.new_string()
var symbolIndArray = array.new_string()
changeIndArray = array.new_float()
trendIndArray = array.new_string()
stochIndArray = array.new_float()

var checkSArray = array.new_bool()
priceSArray = array.new_string()
volSArray = array.new_string()
var symbolSArray = array.new_string()
changeSArray = array.new_float()
trendSArray = array.new_string()
stochSArray = array.new_float()
rsiSArray = array.new_float()
macdSArray = array.new_string()

if barstate.isfirst
    array.push(checkIndArray, a01)
    array.push(checkIndArray, a02)
    array.push(checkIndArray, a03)
    array.push(checkIndArray, a04)
    array.push(checkIndArray, a05)
    array.push(checkIndArray, a06)
    array.push(checkIndArray, a07)
    array.push(checkIndArray, a08)
    array.push(checkIndArray, a09)
    array.push(checkIndArray, a10)
    array.push(checkIndArray, a11)
    array.push(checkIndArray, a12)
    array.push(checkIndArray, a13)
    array.push(checkIndArray, a14)

    array.push(symbolIndArray, i01)
    array.push(symbolIndArray, i02)
    array.push(symbolIndArray, i03)
    array.push(symbolIndArray, i04)
    array.push(symbolIndArray, i05)
    array.push(symbolIndArray, i06)
    array.push(symbolIndArray, i07)
    array.push(symbolIndArray, i08)
    array.push(symbolIndArray, i09)
    array.push(symbolIndArray, i10)
    array.push(symbolIndArray, i11)
    array.push(symbolIndArray, i12)
    array.push(symbolIndArray, i13)
    array.push(symbolIndArray, i14)

    array.push(checkSArray, u01)
    array.push(checkSArray, u02)
    array.push(checkSArray, u03)
    array.push(checkSArray, u04)
    array.push(checkSArray, u05)
    array.push(checkSArray, u06)
    array.push(checkSArray, u07)
    array.push(checkSArray, u08)
    array.push(checkSArray, u09)
    array.push(checkSArray, u10)
    array.push(checkSArray, u11)
    array.push(checkSArray, u12)
    array.push(checkSArray, u13)
    array.push(checkSArray, u14)
    array.push(checkSArray, u15)
    array.push(checkSArray, u16)
    array.push(checkSArray, u17)
    array.push(checkSArray, u18)
    array.push(checkSArray, u19)
    array.push(checkSArray, u20)

    array.push(symbolSArray, s01)
    array.push(symbolSArray, s02)
    array.push(symbolSArray, s03)
    array.push(symbolSArray, s04)
    array.push(symbolSArray, s05)
    array.push(symbolSArray, s06)
    array.push(symbolSArray, s07)
    array.push(symbolSArray, s08)
    array.push(symbolSArray, s09)
    array.push(symbolSArray, s10)
    array.push(symbolSArray, s11)
    array.push(symbolSArray, s12)
    array.push(symbolSArray, s13)
    array.push(symbolSArray, s14)
    array.push(symbolSArray, s15)
    array.push(symbolSArray, s16)
    array.push(symbolSArray, s17)
    array.push(symbolSArray, s18)
    array.push(symbolSArray, s19)
    array.push(symbolSArray, s20)

array.push(priceIndArray, prI1)
array.push(priceIndArray, prI2)
array.push(priceIndArray, prI3)
array.push(priceIndArray, prI4)
array.push(priceIndArray, prI5)
array.push(priceIndArray, prI6)
array.push(priceIndArray, prI7)
array.push(priceIndArray, prI8)
array.push(priceIndArray, prI9)
array.push(priceIndArray, prI10)
array.push(priceIndArray, prI11)
array.push(priceIndArray, prI12)
array.push(priceIndArray, prI13)
array.push(priceIndArray, prI14)



array.push(changeIndArray,chI1)
array.push(changeIndArray, chI2)
array.push(changeIndArray, chI3)
array.push(changeIndArray, chI4)
array.push(changeIndArray, chI5)
array.push(changeIndArray, chI6)
array.push(changeIndArray, chI7)
array.push(changeIndArray, chI8)
array.push(changeIndArray, chI9)
array.push(changeIndArray, chI10)
array.push(changeIndArray, chI11)
array.push(changeIndArray, chI12)
array.push(changeIndArray, chI13)
array.push(changeIndArray, chI14)

array.push(trendIndArray,trendI1)
array.push(trendIndArray, trendI2)
array.push(trendIndArray, trendI3)
array.push(trendIndArray, trendI4)
array.push(trendIndArray, trendI5)
array.push(trendIndArray, trendI6)
array.push(trendIndArray, trendI7)
array.push(trendIndArray, trendI8)
array.push(trendIndArray, trendI9)
array.push(trendIndArray, trendI10)
array.push(trendIndArray, trendI11)
array.push(trendIndArray, trendI12)
array.push(trendIndArray, trendI13)
array.push(trendIndArray, trendI14)

array.push(stochIndArray,stochI1)
array.push(stochIndArray, stochI2)
array.push(stochIndArray, stochI3)
array.push(stochIndArray, stochI4)
array.push(stochIndArray, stochI5)
array.push(stochIndArray, stochI6)
array.push(stochIndArray, stochI7)
array.push(stochIndArray, stochI8)
array.push(stochIndArray, stochI9)
array.push(stochIndArray, stochI10)
array.push(stochIndArray, stochI11)
array.push(stochIndArray, stochI12)
array.push(stochIndArray, stochI13)
array.push(stochIndArray, stochI14)

array.push(priceSArray, prS1)
array.push(priceSArray, prS2)
array.push(priceSArray, prS3)
array.push(priceSArray, prS4)
array.push(priceSArray, prS5)
array.push(priceSArray, prS6)
array.push(priceSArray, prS7)
array.push(priceSArray, prS8)
array.push(priceSArray, prS9)
array.push(priceSArray, prS10)
array.push(priceSArray, prS11)
array.push(priceSArray, prS12)
array.push(priceSArray, prS13)
array.push(priceSArray, prS14)
array.push(priceSArray, prS15)
array.push(priceSArray, prS16)
array.push(priceSArray, prS17)
array.push(priceSArray, prS18)
array.push(priceSArray, prS19)
array.push(priceSArray, prS20)

array.push(volSArray, volS1)
array.push(volSArray, volS2)
array.push(volSArray, volS3)
array.push(volSArray, volS4)
array.push(volSArray, volS5)
array.push(volSArray, volS6)
array.push(volSArray, volS7)
array.push(volSArray, volS8)
array.push(volSArray, volS9)
array.push(volSArray, volS10)
array.push(volSArray, volS11)
array.push(volSArray, volS12)
array.push(volSArray, volS13)
array.push(volSArray, volS14)
array.push(volSArray, volS15)
array.push(volSArray, volS16)
array.push(volSArray, volS17)
array.push(volSArray, volS18)
array.push(volSArray, volS19)
array.push(volSArray, volS20)


array.push(changeSArray,chS1)
array.push(changeSArray, chS2)
array.push(changeSArray, chS3)
array.push(changeSArray, chS4)
array.push(changeSArray, chS5)
array.push(changeSArray, chS6)
array.push(changeSArray, chS7)
array.push(changeSArray, chS8)
array.push(changeSArray, chS9)
array.push(changeSArray, chS10)
array.push(changeSArray, chS11)
array.push(changeSArray, chS12)
array.push(changeSArray, chS13)
array.push(changeSArray, chS14)
array.push(changeSArray, chS15)
array.push(changeSArray, chS16)
array.push(changeSArray, chS17)
array.push(changeSArray, chS18)
array.push(changeSArray, chS19)
array.push(changeSArray, chS20)

array.push(trendSArray,trendS1)
array.push(trendSArray, trendS2)
array.push(trendSArray, trendS3)
array.push(trendSArray, trendS4)
array.push(trendSArray, trendS5)
array.push(trendSArray, trendS6)
array.push(trendSArray, trendS7)
array.push(trendSArray, trendS8)
array.push(trendSArray, trendS9)
array.push(trendSArray, trendS10)
array.push(trendSArray, trendS11)
array.push(trendSArray, trendS12)
array.push(trendSArray, trendS13)
array.push(trendSArray, trendS14)
array.push(trendSArray, trendS15)
array.push(trendSArray, trendS16)
array.push(trendSArray, trendS17)
array.push(trendSArray, trendS18)
array.push(trendSArray, trendS19)
array.push(trendSArray, trendS20)

array.push(stochSArray,stochS1)
array.push(stochSArray, stochS2)
array.push(stochSArray, stochS3)
array.push(stochSArray, stochS4)
array.push(stochSArray, stochS5)
array.push(stochSArray, stochS6)
array.push(stochSArray, stochS7)
array.push(stochSArray, stochS8)
array.push(stochSArray, stochS9)
array.push(stochSArray, stochS10)
array.push(stochSArray, stochS11)
array.push(stochSArray, stochS12)
array.push(stochSArray, stochS13)
array.push(stochSArray, stochS14)
array.push(stochSArray, stochS15)
array.push(stochSArray, stochS16)
array.push(stochSArray, stochS17)
array.push(stochSArray, stochS18)
array.push(stochSArray, stochS19)
array.push(stochSArray, stochS20)

array.push(rsiSArray, rsiS1)
array.push(rsiSArray, rsiS2)
array.push(rsiSArray, rsiS3)
array.push(rsiSArray, rsiS4)
array.push(rsiSArray, rsiS5)
array.push(rsiSArray, rsiS6)
array.push(rsiSArray, rsiS7)
array.push(rsiSArray, rsiS8)
array.push(rsiSArray, rsiS9)
array.push(rsiSArray, rsiS10)
array.push(rsiSArray, rsiS11)
array.push(rsiSArray, rsiS12)
array.push(rsiSArray, rsiS13)
array.push(rsiSArray, rsiS14)
array.push(rsiSArray, rsiS15)
array.push(rsiSArray, rsiS16)
array.push(rsiSArray, rsiS17)
array.push(rsiSArray, rsiS18)
array.push(rsiSArray, rsiS19)
array.push(rsiSArray, rsiS20)

array.push(macdSArray, macdS1)
array.push(macdSArray, macdS2)
array.push(macdSArray, macdS3)
array.push(macdSArray, macdS4)
array.push(macdSArray, macdS5)
array.push(macdSArray, macdS6)
array.push(macdSArray, macdS7)
array.push(macdSArray, macdS8)
array.push(macdSArray, macdS9)
array.push(macdSArray, macdS10)
array.push(macdSArray, macdS11)
array.push(macdSArray, macdS12)
array.push(macdSArray, macdS13)
array.push(macdSArray, macdS14)
array.push(macdSArray, macdS15)
array.push(macdSArray, macdS16)
array.push(macdSArray, macdS17)
array.push(macdSArray, macdS18)
array.push(macdSArray, macdS19)
array.push(macdSArray, macdS20)



selectSize = input.string("Small","Size",["Tiny","Small","Medium","Large","Huge","Auto"],group = "Customize")

titleTextColor =input.color(color.white,"Title Text Color",group = "Customize")
titleColor =input.color(#0b183d,"Title Background Color",group = "Customize")

textColor =input.color(color.white,"Text Color",group = "Customize")
backColor = input.color(#131722,"Background Color",group = "Customize")
borderColor = input.color(color.new(color.white,88),"Border Color",group = "Customize")
frameColor = input.color(#aaaaaa,"Frame Color",group = "Customize")

positiveColor = input.color(color.new(color.green,60),"Positive Color",group = "Customize")
neutralColor = input.color(#131722,"Neutral Color",group = "Customize")
negativeColor = input.color(color.new(color.red,60),"Negative Color",group = "Customize")



var indTab = table.new(getPos(indPos),5,15,bgcolor = backColor,frame_color = frameColor,border_color = borderColor,frame_width = 1,border_width = 1 )
var symTab = table.new(getPos(symPos),8,21,bgcolor = backColor,frame_color = frameColor,border_color = borderColor,frame_width = 1,border_width = 1 )

if barstate.isfirst

    if openIndices
        table.cell(indTab,0,0,"Pair",text_color = titleTextColor,bgcolor = titleColor)
        table.cell(indTab,1,0,"Price",text_color = titleTextColor,bgcolor = titleColor)
        table.cell(indTab,2,0,"Change",text_color = titleTextColor,bgcolor = titleColor,tooltip="Daily Change(%)")
        table.cell(indTab,3,0,"Stoch",text_color = titleTextColor,bgcolor = titleColor)
        table.cell(indTab,4,0,"Trend",text_color = titleTextColor,bgcolor = titleColor)
    
    
    //Symbol Table
    if openSymbols
        table.cell(symTab,0,0,"Pair",text_color = titleTextColor,bgcolor = titleColor)
        table.cell(symTab,1,0,"Price",text_color = titleTextColor,bgcolor = titleColor)
        table.cell(symTab,2,0,"Volume",text_color = titleTextColor,bgcolor = titleColor)
        table.cell(symTab,3,0,"Change",text_color = titleTextColor,bgcolor = titleColor,tooltip="Daily Change(%)")
        table.cell(symTab,4,0,"Stoch",text_color = titleTextColor,bgcolor = titleColor)
        table.cell(symTab,5,0,"Rsi",text_color = titleTextColor,bgcolor = titleColor)
        table.cell(symTab,6,0,"Trend",text_color = titleTextColor,bgcolor = titleColor)
        table.cell(symTab,7,0,"Macd",text_color = titleTextColor,bgcolor = titleColor)

for i=0 to array.size(checkSArray)-1
    if i+1<=array.size(checkIndArray) and openIndices
        check = array.get(checkIndArray,i)
        if check
            sym = syminfo.ticker(array.get(symbolIndArray,i))
            sym := sym=="US05Y/TVC:US10Y" ? "US05Y/US10Y" : sym

            price = array.get(priceIndArray,i)
            change = array.get(changeIndArray,i)
            trend = array.get(trendIndArray,i)
            stoch = array.get(stochIndArray,i)

            changeColor = change>0 ? positiveColor : negativeColor
            trendColor = trend=="Up" ? positiveColor : negativeColor
            stochColor = stoch<=25 ? positiveColor : stoch>75 ? negativeColor : neutralColor

            table.cell(indTab,0,i+1,sym,text_color = textColor,text_size =getSize(selectSize))
            table.cell(indTab,1,i+1,price,text_color = textColor,text_size =getSize(selectSize))
            table.cell(indTab,2,i+1,str.tostring(change,format.percent),text_color = textColor,text_size =getSize(selectSize),bgcolor = changeColor)
            table.cell(indTab,3,i+1,str.tostring(stoch),text_color = textColor,text_size =getSize(selectSize),bgcolor = stochColor)
            table.cell(indTab,4,i+1,trend,text_color = textColor,text_size =getSize(selectSize),bgcolor = trendColor)

    if i+1<=array.size(checkSArray) and openSymbols
        check = array.get(checkSArray,i)    
        if check
            sym = syminfo.ticker(array.get(symbolSArray,i))

            price = array.get(priceSArray,i)
            vol = array.get(volSArray,i)
            change = array.get(changeSArray,i)
            trend = array.get(trendSArray,i)
            stoch = array.get(stochSArray,i)
            rsi = array.get(rsiSArray,i)
            macd = array.get(macdSArray,i)

            changeColor = change>0 ? positiveColor : negativeColor
            trendColor = trend=="Up" ? positiveColor : negativeColor
            stochColor = stoch<=25 ? positiveColor : stoch>75 ? negativeColor : neutralColor
            rsiColor = rsi<=35 ? positiveColor : rsi>=65 ? negativeColor : neutralColor
            macdColor = macd=="Strong\nBullish" ? positiveColor : macd=="Bullish" ? color.new(positiveColor,50) : macd=="Strong\nBearish" ? negativeColor : macd=="Bearish" ? color.new(negativeColor,50) : neutralColor

            table.cell(symTab,0,i+1,sym,text_color = textColor,text_size =getSize(selectSize))
            table.cell(symTab,1,i+1,price,text_color = textColor,text_size =getSize(selectSize))
            table.cell(symTab,2,i+1,vol,text_color = changeColor,text_size =getSize(selectSize))
            table.cell(symTab,3,i+1,str.tostring(change,format.percent),text_color = textColor,text_size =getSize(selectSize),bgcolor = changeColor)
            table.cell(symTab,4,i+1,str.tostring(stoch),text_color = textColor,text_size =getSize(selectSize),bgcolor = stochColor)
            table.cell(symTab,5,i+1,str.tostring(rsi),text_color = textColor,text_size =getSize(selectSize),bgcolor = rsiColor)
            table.cell(symTab,6,i+1,trend,text_color = textColor,text_size =getSize(selectSize),bgcolor = trendColor)
            table.cell(symTab,7,i+1,macd,text_color = textColor,text_size =getSize(selectSize),bgcolor = macdColor)

