SB Multiple Moving Averages (Simple)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SeyfettinBal

//@version=5
indicator("SB Moving Averages", overlay = true)
i = input.source(close,"Source")

l1 = input.int(3, "1. MA Days")
l2 = input.int(5, "2. MA Days")
l3 = input.int(8, "3. MA Days")
l4 = input.int(13, "4. MA Days")
l5 = input.int(21, "5. MA Days")
l6 = input.int(34, "6. MA Days")
l7 = input.int(55, "7. MA Days")


m1 = ta.sma(i, l1) 
m2 = ta.sma(i, l2) 
m3 = ta.sma(i, l3) 
m4 = ta.sma(i, l4) 
m5 = ta.sma(i, l5) 
m6 = ta.sma(i, l6) 
m7 = ta.sma(i, l7) 

c1 = close > m1 ? "+" : "-"
c2 = close > m2 ? "+" : "-"
c3 = close > m3 ? "+" : "-"
c4 = close > m4 ? "+" : "-"
c5 = close > m5 ? "+" : "-"
c6 = close > m6 ? "+" : "-"
c7 = close > m7 ? "+" : "-"

color1 = (c1 == "+" ? color.lime : color.red)
color2 = (c2 == "+" ? color.lime : color.red)
color3 = (c3 == "+" ? color.lime : color.red)
color4 = (c4 == "+" ? color.lime : color.red)
color5 = (c5 == "+" ? color.lime : color.red)
color6 = (c6 == "+" ? color.lime : color.red)
color7 = (c7 == "+" ? color.lime : color.red)

li = input.int(2, "Linewidth")

plot(m1, "MA 1", color = color.yellow, linewidth = li)
plot(m2, "MA 2", color = color.orange, linewidth = li)
plot(m3, "MA 3", color = color.aqua, linewidth = li)
plot(m4, "MA 4", color = color.blue, linewidth = li)
plot(m5, "MA 5", color = color.red, linewidth = li)
plot(m6, "MA 6", color = color.purple, linewidth = li)
plot(m7, "MA 7", color = color.black, linewidth = li)


var myTable = table.new(position = position.top_right, columns = 2, rows = 9, bgcolor = color.rgb(207, 255, 255), frame_color = #313131, frame_width = 2, border_color = #818181, border_width = 1)

table.cell(table_id = myTable, column = 0, row = 0, text = str.tostring(syminfo.ticker), text_color = color.white, bgcolor = color.rgb(0, 79, 144), width = 7.5)
table.cell(table_id = myTable, column = 0, row = 1, text =  "MA 1", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 2, text =  "MA 2", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 3, text =  "MA 3", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 4, text =  "MA 4", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 5, text =  "MA 5", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 6, text =  "MA 6", text_color = #313131, bgcolor = color.rgb(232, 232, 232))
table.cell(table_id = myTable, column = 0, row = 7, text =  "MA 7", text_color = #313131, bgcolor = color.rgb(232, 232, 232))


table.cell(table_id = myTable, column=1, row=0, text = "Position", text_color = color.white, bgcolor = color.rgb(0, 79, 144), width = 7.5)
table.cell(table_id = myTable, column = 1, row = 1, text = str.tostring(c1), text_color = #313131, bgcolor = color1)
table.cell(table_id = myTable, column = 1, row = 2, text = str.tostring(c2), text_color = #313131, bgcolor = color2)
table.cell(table_id = myTable, column = 1, row = 3, text = str.tostring(c3), text_color = #313131, bgcolor = color3)
table.cell(table_id = myTable, column = 1, row = 4, text = str.tostring(c4), text_color = #313131, bgcolor = color4)
table.cell(table_id = myTable, column = 1, row = 5, text = str.tostring(c5), text_color = #313131, bgcolor = color5)
table.cell(table_id = myTable, column = 1, row = 6, text = str.tostring(c6), text_color = #313131, bgcolor = color6)
table.cell(table_id = myTable, column = 1, row = 7, text = str.tostring(c7), text_color = #313131, bgcolor = color7)