Breadth Ratio Bubbles
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © auron9000

//@version=5
indicator("Breadth Ratio Bubbles", overlay=true)

//Up and down VOL for NYSE and NASDAQ
UVOL = request.security("UVOL","",close)
DVOL = request.security("DVOL","",close)
UVOLQ = request.security("UVOLQ","",close)
DVOLQ = request.security("DVOLQ","",close)

//NYSE Breadth
NYSEratio = UVOL >= DVOL ? UVOL/DVOL : -(DVOL/UVOL)
//plot(NYSEratio)

//NASDAQ Breadth
NASDAQratio = UVOLQ >= DVOLQ ? UVOLQ/DVOLQ : -(DVOLQ/UVOLQ)
//plot(NASDAQratio)

//Table Creation
var table breadthTable = table.new(position.top_left, 2, 1, border_color = color.black, border_width = 2)

//Plot Table
if barstate.islast
    table.cell(breadthTable, 0, 0, str.tostring(NYSEratio, format.mintick) + ":1 NYSE", text_size = size.large, text_color = #000000, bgcolor = NYSEratio > 0 ? color.green : color.red)
    table.cell(breadthTable, 1, 0, str.tostring(NASDAQratio, format.mintick) + ":1 NASD", text_size = size.large, text_color = #000000, bgcolor = NASDAQratio > 0 ? color.green : color.red)
    
// Plot Zero Line
plot(0, color = NYSEratio > 0 ? color.green : color.red)