SPY DXY VIX Monitor
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © peacefulLizard50262

//@version=5
indicator("I SPY", overlay = true)
diff(_src) =>
    (_src + 2 * _src[1] - 2 * _src[3] - _src[4]) / 8


style = input.string("Middle Right", "Position", 
 ["Bottom Left","Bottom Middle","Bottom Right","Middle Left","Middle Center","Middle Right",
 "Top Left","Top Middle","Top Right"])
txt_col = input.color(color.new(#c8d7ff, 0), "Title Color", inline = "bull", group = "Settings")
box_col = input.color(color.new(#202236, 10), "", inline = "bull", group = "Settings")

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

spy = request.security("SPY", timeframe.period , close)
dxy = request.security("DXY", timeframe.period , close)
vix = request.security("VIX", timeframe.period , close)
us10y = request.security("US10Y", timeframe.period , close)

var tbl = table.new(location(), 4, 5)
if barstate.islast
    table.cell(tbl, 0, 0, "Symbol", text_color = txt_col, bgcolor = box_col, tooltip = "Symbol for that line.")
    table.cell(tbl, 1, 0, "Price", text_color = txt_col, bgcolor = box_col, tooltip = "Price of Symbol")
    table.cell(tbl, 2, 0, "Direction", text_color = txt_col, bgcolor = box_col, tooltip = "Direction of the Symbol")

main(name, source, n) =>
    exn  = name
    dir  = diff(source)
    Diff_Score = dir < 0 ? "↓" : dir > 0 ? "↑" : "→"
    if barstate.islast
        table.cell(tbl, 0, n, exn, text_color = txt_col, bgcolor = box_col)
        table.cell(tbl, 1, n, str.tostring(source), text_color = txt_col, bgcolor = box_col)
        table.cell(tbl, 2, n, Diff_Score, text_color = txt_col, bgcolor = box_col)

main("SPY", spy, 1)
main("DXY", dxy, 2)
main("VIX", vix, 3)
main("US10Y", us10y, 4)