Add Volume of Multiple Securities
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © joe.dodaro
//@version=5


indicator("Add Volume of Multiple Symbols")

// ratio multiplies volume by any number you'd like, for any reason you'd like
ratio = input(1.000000000)

// these are the inputs for symbols
symbolInput1 = input.symbol("", "Symbol1", inline = "sym1")
symbolInput2 = input.symbol("", "Symbol2", inline = "sym2")
symbolInput3 = input.symbol("", "Symbol3", inline = "sym3")
symbolInput4 = input.symbol("", "Symbol4", inline = "sym4")
symbolInput5 = input.symbol("", "Symbol5", inline = "sym5")
symbolInput6 = input.symbol("", "Symbol6", inline = "sym6")
symbolInput7 = input.symbol("", "Symbol7", inline = "sym7")
symbolInput8 = input.symbol("", "Symbol8", inline = "sym8")
symbolInput9 = input.symbol("", "Symbol9", inline = "sym9")
symbolInput10 = input.symbol("", "Symbol10", inline = "sym10")
symbolInput11 = input.symbol("", "Symbol11", inline = "sym11")
symbolInput12 = input.symbol("", "Symbol12", inline = "sym12")
symbolInput13 = input.symbol("", "Symbol13", inline = "sym13")
symbolInput14 = input.symbol("", "Symbol14", inline = "sym14")
symbolInput15 = input.symbol("", "Symbol15", inline = "sym15")
symbolInput16 = input.symbol("", "Symbol16", inline = "sym16")
symbolInput17 = input.symbol("", "Symbol17", inline = "sym17")
symbolInput18 = input.symbol("", "Symbol18", inline = "sym18")
symbolInput19 = input.symbol("", "Symbol19", inline = "sym19")
symbolInput20 = input.symbol("", "Symbol20", inline = "sym20")
symbolInput21 = input.symbol("", "Symbol21", inline = "sym21")
symbolInput22 = input.symbol("", "Symbol22", inline = "sym22")
symbolInput23 = input.symbol("", "Symbol23", inline = "sym23")
symbolInput24 = input.symbol("", "Symbol24", inline = "sym24")
symbolInput25 = input.symbol("", "Symbol25", inline = "sym25")
symbolInput26 = input.symbol("", "Symbol26", inline = "sym26")
symbolInput27 = input.symbol("", "Symbol27", inline = "sym27")
symbolInput28 = input.symbol("", "Symbol28", inline = "sym28")
symbolInput29 = input.symbol("", "Symbol29", inline = "sym29")
symbolInput30 = input.symbol("", "Symbol30", inline = "sym30")
symbolInput31 = input.symbol("", "Symbol31", inline = "sym31")
symbolInput32 = input.symbol("", "Symbol32", inline = "sym32")
symbolInput33 = input.symbol("", "Symbol33", inline = "sym33")
symbolInput34 = input.symbol("", "Symbol34", inline = "sym34")
symbolInput35 = input.symbol("", "Symbol35", inline = "sym35")
symbolInput36 = input.symbol("", "Symbol36", inline = "sym36")
symbolInput37 = input.symbol("", "Symbol37", inline = "sym37")
symbolInput38 = input.symbol("", "Symbol38", inline = "sym38")
symbolInput39 = input.symbol("", "Symbol39", inline = "sym39")

//these are the options for choosing a symbol ... including in the calc or not

symbol1= input(false, inline = "sym1")
sym1= request.security(symbolInput1, timeframe.period, volume)
symbol2= input(false, inline = "sym2")
sym2= request.security(symbolInput2, timeframe.period, volume)
symbol3= input(false, inline = "sym3")
sym3= request.security(symbolInput3, timeframe.period, volume)
symbol4= input(false, inline = "sym4")
sym4= request.security(symbolInput4, timeframe.period, volume)
symbol5= input(false, inline = "sym5")
sym5= request.security(symbolInput5, timeframe.period, volume)
symbol6= input(false, inline = "sym6")
sym6= request.security(symbolInput6, timeframe.period, volume)
symbol7= input(false, inline = "sym7")
sym7= request.security(symbolInput7, timeframe.period, volume)
symbol8= input(false, inline = "sym8")
sym8= request.security(symbolInput8, timeframe.period, volume)
symbol9= input(false, inline = "sym9")
sym9= request.security(symbolInput9, timeframe.period, volume)
symbol10= input(false, inline = "sym10")
sym10= request.security(symbolInput10, timeframe.period, volume)
symbol11= input(false, inline = "sym11")
sym11= request.security(symbolInput11, timeframe.period, volume)
symbol12= input(false, inline = "sym12")
sym12= request.security(symbolInput12, timeframe.period, volume)
symbol13= input(false, inline = "sym13")
sym13= request.security(symbolInput13, timeframe.period, volume)
symbol14= input(false, inline = "sym14")
sym14= request.security(symbolInput14, timeframe.period, volume)
symbol15= input(false, inline = "sym15")
sym15= request.security(symbolInput15, timeframe.period, volume)
symbol16= input(false, inline = "sym16")
sym16= request.security(symbolInput16, timeframe.period, volume)
symbol17= input(false, inline = "sym17")
sym17= request.security(symbolInput17, timeframe.period, volume)
symbol18= input(false, inline = "sym18")
sym18= request.security(symbolInput18, timeframe.period, volume)
symbol19= input(false, inline = "sym19")
sym19= request.security(symbolInput19, timeframe.period, volume)
symbol20= input(false, inline = "sym20")
sym20= request.security(symbolInput20, timeframe.period, volume)
symbol21= input(false, inline = "sym21")
sym21= request.security(symbolInput21, timeframe.period, volume)
symbol22= input(false, inline = "sym22")
sym22= request.security(symbolInput22, timeframe.period, volume)
symbol23= input(false, inline = "sym23")
sym23= request.security(symbolInput23, timeframe.period, volume)
symbol24= input(false, inline = "sym24")
sym24= request.security(symbolInput24, timeframe.period, volume)
symbol25= input(false, inline = "sym25")
sym25= request.security(symbolInput25, timeframe.period, volume)
symbol26= input(false, inline = "sym26")
sym26= request.security(symbolInput26, timeframe.period, volume)
symbol27= input(false, inline = "sym27")
sym27= request.security(symbolInput27, timeframe.period, volume)
symbol28= input(false, inline = "sym28")
sym28= request.security(symbolInput28, timeframe.period, volume)
symbol29= input(false, inline = "sym29")
sym29= request.security(symbolInput29, timeframe.period, volume)
symbol30= input(false, inline = "sym30")
sym30= request.security(symbolInput30, timeframe.period, volume)
symbol31= input(false, inline = "sym31")
sym31= request.security(symbolInput31, timeframe.period, volume)
symbol32= input(false, inline = "sym32")
sym32= request.security(symbolInput32, timeframe.period, volume)
symbol33= input(false, inline = "sym33")
sym33= request.security(symbolInput33, timeframe.period, volume)
symbol34= input(false, inline = "sym34")
sym34= request.security(symbolInput34, timeframe.period, volume)
symbol35= input(false, inline = "sym35")
sym35= request.security(symbolInput35, timeframe.period, volume)
symbol36= input(false, inline = "sym36")
sym36= request.security(symbolInput36, timeframe.period, volume)
symbol37= input(false, inline = "sym37")
sym37= request.security(symbolInput37, timeframe.period, volume)
symbol38= input(false, inline = "sym38")
sym38= request.security(symbolInput38, timeframe.period, volume)
symbol39= input(false, inline = "sym39")
sym39= request.security(symbolInput39, timeframe.period, volume)

// total combined volume amount defined
vall = 0.0000000000

// ability to divide the individual inputs by the closing price of the candle
// for crypto mainly - some volume is calculated in USD (a good example is the FTX BTCUSD pair)
// allows you to convert the volume into "shares" (in this case amount of BTC instead of USD)

sym1_divbyclose= input(false, inline = "sym1")
sym1_ratio = 1.0000000000
if sym1_divbyclose
    sym1_ratio := close
if symbol1
    vall := vall + (sym1 / sym1_ratio)
    
sym2_divbyclose= input(false, inline = "sym2")
sym2_ratio = 1.0000000000
if sym2_divbyclose
    sym2_ratio := close
if symbol2
    vall := vall + (sym2 / sym2_ratio)

sym3_divbyclose= input(false, inline = "sym3")
sym3_ratio = 1.0000000000
if sym3_divbyclose
    sym3_ratio := close
if symbol3
    vall := vall + (sym3 / sym3_ratio)
    
sym4_divbyclose= input(false, inline = "sym4")
sym4_ratio = 1.0000000000
if sym4_divbyclose
    sym4_ratio := close
if symbol4
    vall := vall + (sym4 / sym4_ratio)
    
sym5_divbyclose= input(false, inline = "sym5")
sym5_ratio = 1.0000000000
if sym5_divbyclose
    sym5_ratio := close
if symbol5
    vall := vall + (sym5 / sym5_ratio)

sym6_divbyclose= input(false, inline = "sym6")
sym6_ratio = 1.0000000000
if sym6_divbyclose
    sym6_ratio := close 
if symbol6
    vall := vall + (sym6 / sym6_ratio)
    
sym7_divbyclose= input(false, inline = "sym7")
sym7_ratio = 1.0000000000
if sym7_divbyclose
    sym7_ratio := close  
if symbol7 
    vall := vall + (sym7 / sym7_ratio)
    
sym8_divbyclose= input(false, inline = "sym8")
sym8_ratio = 1.0000000000
if sym8_divbyclose
    sym8_ratio := close
if symbol8 
    vall := vall + (sym8 / sym8_ratio)
    
sym9_divbyclose= input(false, inline = "sym9")
sym9_ratio = 1.0000000000
if sym9_divbyclose
    sym9_ratio := close  
if symbol9
    vall := vall + (sym9 / sym9_ratio)
    
sym10_divbyclose= input(false, inline = "sym10")
sym10_ratio = 1.0000000000
if sym10_divbyclose
    sym10_ratio := close  
if symbol10
    vall := vall + (sym10 / sym10_ratio)
    
sym11_divbyclose= input(false, inline = "sym11")
sym11_ratio = 1.0000000000
if sym11_divbyclose
    sym11_ratio := close  
if symbol11
    vall := vall + (sym11 / sym11_ratio)
    
sym12_divbyclose= input(false, inline = "sym12")
sym12_ratio = 1.0000000000
if sym12_divbyclose
    sym12_ratio := close
if symbol12
    vall := vall + (sym12 / sym12_ratio)

sym13_divbyclose= input(false, inline = "sym13")
sym13_ratio = 1.0000000000
if sym13_divbyclose
    sym13_ratio := close
if symbol13
    vall := vall + (sym13 / sym13_ratio)

sym14_divbyclose= input(false, inline = "sym14")
sym14_ratio = 1.0000000000
if sym14_divbyclose
    sym14_ratio := close
if symbol14
    vall := vall + (sym14 / sym14_ratio)
    
sym15_divbyclose= input(false, inline = "sym15")
sym15_ratio = 1.0000000000
if sym15_divbyclose
    sym15_ratio := close
if symbol15
    vall := vall + (sym15 / sym15_ratio)
    
sym16_divbyclose= input(false, inline = "sym16")
sym16_ratio = 1.0000000000
if sym16_divbyclose
    sym16_ratio := close
if symbol16
    vall := vall + (sym16 / sym16_ratio)
    
sym17_divbyclose= input(false, inline = "sym17")
sym17_ratio = 1.0000000000
if sym17_divbyclose
    sym17_ratio := close 
if symbol17
    vall := vall + (sym17 / sym17_ratio)
    
sym18_divbyclose= input(false, inline = "sym18")
sym18_ratio = 1.0000000000
if sym18_divbyclose
    sym18_ratio := close
if symbol18
    vall := vall + (sym18 / sym18_ratio)
    
sym19_divbyclose= input(false, inline = "sym19")
sym19_ratio = 1.0000000000
if sym19_divbyclose
    sym19_ratio := close
if symbol19
    vall := vall + (sym19 / sym19_ratio)

sym20_divbyclose= input(false, inline = "sym20")
sym20_ratio = 1.0000000000
if sym20_divbyclose
    sym20_ratio := close
if symbol20
    vall := vall + (sym20 / sym20_ratio)
    
sym21_divbyclose= input(false, inline = "sym21")
sym21_ratio = 1.0000000000
if sym21_divbyclose
    sym21_ratio := close
if symbol21
    vall := vall + (sym21 / sym21_ratio)
    
sym22_divbyclose= input(false, inline = "sym22")
sym22_ratio = 1.0000000000
if sym22_divbyclose
    sym22_ratio := close
if symbol22
    vall := vall + (sym22 / sym22_ratio)
    
sym23_divbyclose= input(false, inline = "sym23")
sym23_ratio = 1.0000000000
if sym23_divbyclose
    sym23_ratio := close  
if symbol23
    vall := vall + (sym23 / sym23_ratio)
    
sym24_divbyclose= input(false, inline = "sym24")
sym24_ratio = 1.0000000000
if sym24_divbyclose
    sym24_ratio := close  
if symbol24
    vall := vall + (sym24 / sym24_ratio)
    
sym25_divbyclose= input(false, inline = "sym25")
sym25_ratio = 1.0000000000
if sym25_divbyclose
    sym25_ratio := close
if symbol25
    vall := vall + (sym25 / sym25_ratio)
    
sym26_divbyclose= input(false, inline = "sym26")
sym26_ratio = 1.0000000000
if sym26_divbyclose
    sym26_ratio := close 
if symbol26
    vall := vall + (sym26 / sym26_ratio)
    
sym27_divbyclose= input(false, inline = "sym27")
sym27_ratio = 1.0000000000
if sym27_divbyclose
    sym27_ratio := close  
if symbol27
    vall := vall + (sym27 / sym27_ratio)
    
sym28_divbyclose= input(false, inline = "sym28")
sym28_ratio = 1.0000000000
if sym28_divbyclose
    sym28_ratio := close 
if symbol28
    vall := vall + (sym28 / sym28_ratio)
    
sym29_divbyclose= input(false, inline = "sym29")
sym29_ratio = 1.0000000000
if sym29_divbyclose
    sym29_ratio := close   
if symbol29
    vall := vall + (sym29 / sym29_ratio)
    
sym30_divbyclose= input(false, inline = "sym30")
sym30_ratio = 1.0000000000
if sym30_divbyclose
    sym30_ratio := close
if symbol30
    vall := vall + (sym30 / sym30_ratio)
    
sym31_divbyclose= input(false, inline = "sym31")
sym31_ratio = 1.0000000000
if sym31_divbyclose
    sym31_ratio := close
if symbol31
    vall := vall + (sym31 / sym31_ratio)
    
sym32_divbyclose= input(false, inline = "sym32")
sym32_ratio = 1.0000000000
if sym32_divbyclose
    sym32_ratio := close
if symbol32
    vall := vall + (sym32 / sym32_ratio)
    
sym33_divbyclose= input(false, inline = "sym33")
sym33_ratio = 1.0000000000
if sym33_divbyclose
    sym33_ratio := close 
if symbol33
    vall := vall + (sym33 / sym33_ratio)
    
sym34_divbyclose= input(false, inline = "sym34")
sym34_ratio = 1.0000000000
if sym34_divbyclose
    sym34_ratio := close
if symbol34
    vall := vall + (sym34 / sym34_ratio)
    
sym35_divbyclose= input(false, inline = "sym35")
sym35_ratio = 1.0000000000
if sym35_divbyclose
    sym35_ratio := close  
if symbol35
    vall := vall + (sym35 / sym35_ratio)
    
sym36_divbyclose= input(false, inline = "sym36")
sym36_ratio = 1.0000000000
if sym36_divbyclose
    sym36_ratio := close
if symbol36
    vall := vall + (sym36 / sym36_ratio)
    
sym37_divbyclose= input(false, inline = "sym37")
sym37_ratio = 1.0000000000
if sym37_divbyclose
    sym37_ratio := close  
if symbol37
    vall := vall + (sym37 / sym37_ratio)
    
sym38_divbyclose= input(false, inline = "sym38")
sym38_ratio = 1.0000000000
if sym38_divbyclose
    sym38_ratio := close  
if symbol38
    vall := vall + (sym38 / sym38_ratio)
    
sym39_divbyclose= input(false, inline = "sym39")
sym39_ratio = 1.0000000000
if sym39_divbyclose
    sym39_ratio := close  
if symbol39
    vall := vall + (sym38 / sym39_ratio)

// Plot for volume & for volume 20ma

plot(vall*ratio, style=plot.style_histogram)
plot(ta.sma(vall*ratio,20),style=plot.style_line)
