Stock Strength Index by zdmre
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © zdmre

//@version=5
indicator("Stock Strength Index by zdmre")

// INPUTs
sym1 = input.symbol("NASDAQ:AAPL",title = "1")
sym2 = input.symbol("NASDAQ:AMD",title = "2")
sym3 = input.symbol("NASDAQ:AMZN",title = "3")
sym4 = input.symbol("NASDAQ:TSLA",title = "4")
sym5 = input.symbol("NASDAQ:NFLX",title = "5")
sym6 = input.symbol("NASDAQ:META",title = "6")
sym7 = input.symbol("NASDAQ:INTC",title = "7")
sym8 = input.symbol("NYSE:BABA",title = "8")

opt_textsize = input.string(size.small, 'Text Size', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge])

Show1 = input(true, "Symbol 1", group= "SHOW")
Show2 = input(true, "Symbol 2", group= "SHOW")
Show3 = input(true, "Symbol 3", group= "SHOW")
Show4 = input(true, "Symbol 4", group= "SHOW")
Show5 = input(true, "Symbol 5", group= "SHOW")
Show6 = input(true, "Symbol 6", group= "SHOW")
Show7 = input(true, "Symbol 7", group= "SHOW")
Show8 = input(true, "Symbol 8", group= "SHOW")

// CALC
rma = ta.rma(close, 200)
rq_sym1 = request.security(sym1, "240", close , barmerge.gaps_off, barmerge.lookahead_off)
sym1_rma = request.security(sym1, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym2 = request.security(sym2, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym2_rma = request.security(sym2, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym3 = request.security(sym3, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym3_rma = request.security(sym3, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym4 = request.security(sym4, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym4_rma = request.security(sym4, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym5 = request.security(sym5, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym5_rma = request.security(sym5, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym6 = request.security(sym6, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym6_rma = request.security(sym6, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym7 = request.security(sym7, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym7_rma = request.security(sym7, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)
rq_sym8 = request.security(sym8, "240", close, barmerge.gaps_off, barmerge.lookahead_off)
sym8_rma = request.security(sym8, "240", rma, barmerge.gaps_off, barmerge.lookahead_off)

str_sym1 = (rq_sym1 - sym1_rma)/rq_sym1 * 100
str_sym2 = (rq_sym2 - sym2_rma)/rq_sym2 * 100
str_sym3 = (rq_sym3 - sym3_rma)/rq_sym3 * 100
str_sym4 = (rq_sym4 - sym4_rma)/rq_sym4 * 100
str_sym5 = (rq_sym5 - sym5_rma)/rq_sym5 * 100
str_sym6 = (rq_sym6 - sym6_rma)/rq_sym6 * 100
str_sym7 = (rq_sym7 - sym7_rma)/rq_sym7 * 100
str_sym8 = (rq_sym8 - sym8_rma)/rq_sym8 * 100

// LABELs
ShowLabels = input(true, "Show Labels")
if (ShowLabels)
    style = label.style_label_left
    size = opt_textsize
    if (Show1)
        label lbl1 = label.new(bar_index+1, str_sym1, syminfo.ticker(sym1), color=color.yellow,   style=style, textcolor=color.black, size=size), label.delete(lbl1[1])
    if (Show2)
        label lbl2 = label.new(bar_index+1, str_sym2, syminfo.ticker(sym2), color=color.green,  style=style, textcolor=color.black, size=size), label.delete(lbl2[1])
    if (Show3)
        label lbl3 = label.new(bar_index+1, str_sym3, syminfo.ticker(sym3), color=color.purple,    style=style, textcolor=color.black, size=size), label.delete(lbl3[1])
    if (Show4)
        label lbl4 = label.new(bar_index+1, str_sym4, syminfo.ticker(sym4), color=color.blue, style=style, textcolor=color.white, size=size), label.delete(lbl4[1])
    if (Show5)
        label lbl5 = label.new(bar_index+1, str_sym5, syminfo.ticker(sym5), color=color.red,   style=style, textcolor=color.black, size=size), label.delete(lbl5[1])
    if (Show6)
        label lbl6 = label.new(bar_index+1, str_sym6, syminfo.ticker(sym6), color=color.orange,   style=style, textcolor=color.black, size=size), label.delete(lbl6[1])
    if (Show7)
        label lbl7 = label.new(bar_index+1, str_sym7, syminfo.ticker(sym7), color=color.teal,style=style, textcolor=color.black, size=size), label.delete(lbl7[1])
    if (Show8)
        label lbl8 = label.new(bar_index+1, str_sym8, syminfo.ticker(sym8), color=color.aqua, style=style, textcolor=color.black, size=size), label.delete(lbl8[1])

// TABLE
var tbis = table.new(position.middle_right, 3, 9, frame_color=color.black, frame_width=0, border_width=1, border_color=color.black)

table.cell(tbis, 0, 0, 'STOCK', bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
table.cell(tbis, 1, 0, 'INDEX', bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
table.cell(tbis, 2, 0, 'DAY', bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
if Show1
    table.cell(tbis, 0, 1, syminfo.ticker(sym1), bgcolor = color.yellow, text_size=opt_textsize, text_color=color.black)
    table.cell(tbis, 1, 1, str.tostring(str_sym1[0], '#,##0.00'), text_color=str_sym1[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym1[0] < 0 ? color.red : str_sym1[0] > 0 ? color.lime : color.black)
    table.cell(tbis, 2, 1, str.tostring((str_sym1[0]-str_sym1[1]), '#,##0.00'), text_color=(str_sym1[0]-str_sym1[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym1[0]-str_sym1[1]) < 0 ? color.red : (str_sym1[0]-str_sym1[1]) > 0 ? color.lime : color.black)
if Show2
    table.cell(tbis, 0, 2, syminfo.ticker(sym2), bgcolor = color.green, text_size=opt_textsize, text_color=color.black)
    table.cell(tbis, 1, 2, str.tostring(str_sym2[0], '#,##0.00'), text_color=str_sym2[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym2[0] < 0 ? color.red : str_sym2[0] > 0 ? color.lime : color.black)
    table.cell(tbis, 2, 2, str.tostring((str_sym2[0]-str_sym2[1]), '#,##0.00'), text_color=(str_sym2[0]-str_sym2[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym2[0]-str_sym2[1]) < 0 ? color.red : (str_sym2[0]-str_sym2[1]) > 0 ? color.lime : color.black)
if Show3
    table.cell(tbis, 0, 3, syminfo.ticker(sym3), bgcolor = color.purple, text_size=opt_textsize, text_color=color.black)
    table.cell(tbis, 1, 3, str.tostring(str_sym3[0], '#,##0.00'), text_color=str_sym3[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym3[0] < 0 ? color.red : str_sym3[0] > 0 ? color.lime : color.black)
    table.cell(tbis, 2, 3, str.tostring((str_sym3[0]-str_sym3[1]), '#,##0.00'), text_color=(str_sym3[0]-str_sym3[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym3[0]-str_sym3[1]) < 0 ? color.red : (str_sym3[0]-str_sym3[1]) > 0 ? color.lime : color.black)
if Show4
    table.cell(tbis, 0, 4, syminfo.ticker(sym4), bgcolor = color.blue, text_size=opt_textsize, text_color=color.white)
    table.cell(tbis, 1, 4, str.tostring(str_sym4[0], '#,##0.00'), text_color=str_sym4[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym4[0] < 0 ? color.red : str_sym4[0] > 0 ? color.lime : color.black)
    table.cell(tbis, 2, 4, str.tostring((str_sym4[0]-str_sym4[1]), '#,##0.00'), text_color=(str_sym4[0]-str_sym4[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym4[0]-str_sym4[1]) < 0 ? color.red : (str_sym4[0]-str_sym4[1]) > 0 ? color.lime : color.black)
if Show5
    table.cell(tbis, 0, 5, syminfo.ticker(sym5), bgcolor = color.red, text_size=opt_textsize, text_color=color.black)
    table.cell(tbis, 1, 5, str.tostring(str_sym5[0], '#,##0.00'), text_color=str_sym5[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym5[0] < 0 ? color.red : str_sym5[0] > 0 ? color.lime : color.black)
    table.cell(tbis, 2, 5, str.tostring((str_sym5[0]-str_sym5[1]), '#,##0.00'), text_color=(str_sym5[0]-str_sym5[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym5[0]-str_sym5[1]) < 0 ? color.red : (str_sym5[0]-str_sym5[1]) > 0 ? color.lime : color.black)
if Show6
    table.cell(tbis, 0, 6, syminfo.ticker(sym6), bgcolor = color.orange, text_size=opt_textsize, text_color=color.black)
    table.cell(tbis, 1, 6, str.tostring(str_sym6[0], '#,##0.00'), text_color=str_sym6[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym6[0] < 0 ? color.red : str_sym6[0] > 0 ? color.lime : color.black)
    table.cell(tbis, 2, 6, str.tostring((str_sym6[0]-str_sym6[1]), '#,##0.00'), text_color=(str_sym6[0]-str_sym6[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym6[0]-str_sym6[1]) < 0 ? color.red : (str_sym6[0]-str_sym6[1]) > 0 ? color.lime : color.black)
if Show7
    table.cell(tbis, 0, 7, syminfo.ticker(sym7), bgcolor = color.teal, text_size=opt_textsize, text_color=color.black)
    table.cell(tbis, 1, 7, str.tostring(str_sym7[0], '#,##0.00'), text_color=str_sym7[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym7[0] < 0 ? color.red : str_sym7[0] > 0 ? color.lime : color.black)
    table.cell(tbis, 2, 7, str.tostring((str_sym7[0]-str_sym7[1]), '#,##0.00'), text_color=(str_sym7[0]-str_sym7[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym7[0]-str_sym7[1]) < 0 ? color.red : (str_sym7[0]-str_sym7[1]) > 0 ? color.lime : color.black)
if Show8
    table.cell(tbis, 0, 8, syminfo.ticker(sym8), bgcolor = color.aqua, text_size=opt_textsize, text_color=color.black)
    table.cell(tbis, 1, 8, str.tostring(str_sym8[0], '#,##0.00'), text_color=str_sym8[0] > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= str_sym8[0] < 0 ? color.red : str_sym8[0] > 0 ? color.lime : color.black)
    table.cell(tbis, 2, 8, str.tostring((str_sym8[0]-str_sym8[1]), '#,##0.00'), text_color=(str_sym8[0]-str_sym8[1]) > 0 ? color.black : color.white, text_size=opt_textsize, bgcolor= (str_sym8[0]-str_sym8[1]) < 0 ? color.red : (str_sym8[0]-str_sym8[1]) > 0 ? color.lime : color.black)


// LINEs
plot(Show1 ? str_sym1 : na, "1", color=color.yellow)
plot(Show2 ? str_sym2 : na, "2", color=color.green)
plot(Show3 ? str_sym3 : na, "3", color=color.purple)
plot(Show4 ? str_sym4 : na, "4", color=color.blue)
plot(Show5 ? str_sym5 : na, "5", color=color.red)
plot(Show6 ? str_sym6 : na, "6", color=color.orange)
plot(Show7 ? str_sym7 : na, "7", color=color.teal)
plot(Show8 ? str_sym8 : na, "8", color=color.aqua)

bandh = hline(50, title= "Upper Band", color=color.new(#787B86, 50), display=display.none)
band0 = hline(0, title= "USD", color=color.new(#787B86, 0), linewidth=2)
bandl = hline(-50, title= "Lower Band", color=color.new(#787B86, 50), display=display.none)