Crypto Aggregated Volume «NoaTrader»
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © noafarin

//@version=5
indicator("Crypto Aggregated Spot Volume «NoaTrader»","AGG VOL",overlay = false,max_labels_count = 500)
var ma_len = input.int(1000,"Average Length")
var vol_mult = input.float(3,"Multiplier for Label") // 5 for 15m
var avg_method = input.string("SMA","Average Method",["SMA","EMA","HMA"])
var exclude_binance = input.bool(false,"Exclude Binance")
binance_usdt = exclude_binance ? 0 : nz(request.security("BINANCE:"+ syminfo.basecurrency+"USDT","",volume,ignore_invalid_symbol = true))
binance_busd = exclude_binance ? 0 : nz(request.security("BINANCE:"+ syminfo.basecurrency+"BUSD","",volume,ignore_invalid_symbol = true))
binance_fdusd = exclude_binance ? 0 : nz(request.security("BINANCE:"+ syminfo.basecurrency+"FDUSD","",volume,ignore_invalid_symbol = true))
binance_tusd = exclude_binance ? 0 : nz(request.security("BINANCE:"+ syminfo.basecurrency+"TUSD","",volume,ignore_invalid_symbol = true))
bitstamp = nz(request.security("BITSTAMP:"+ syminfo.ticker,"",volume,ignore_invalid_symbol = true))
coinbase = nz(request.security("COINBASE:"+ syminfo.ticker,"",volume,ignore_invalid_symbol = true))
huobi = nz(request.security("HUOBI:"+ syminfo.ticker,"",volume,ignore_invalid_symbol = true))
kraken = nz(request.security("KRAKEN:"+ syminfo.ticker,"",volume,ignore_invalid_symbol = true))
bitfinex = nz(request.security("BITFINEX:"+ syminfo.ticker,"",volume,ignore_invalid_symbol = true))
bybit = nz(request.security("BYBIT:"+ syminfo.ticker,"",volume,ignore_invalid_symbol = true))
okx = nz(request.security("OKX:"+ syminfo.ticker,"",volume,ignore_invalid_symbol = true))
kucoin = nz(request.security("KUCOIN:"+ syminfo.ticker,"",volume,ignore_invalid_symbol = true))
bithumb = nz(request.security("BITHUMB:"+ syminfo.ticker,"",volume,ignore_invalid_symbol = true))

agg_vol = binance_usdt + binance_tusd + binance_fdusd + binance_busd + bitstamp + coinbase + huobi + kraken + bitfinex + bybit + okx + kucoin + bithumb


vol_clr = color.from_gradient(agg_vol,ta.lowest(agg_vol,int(ma_len/20)),int(ta.highest(agg_vol,int(ma_len/20))*0.618),color.red,color.green)
plot(agg_vol,color=vol_clr,style=plot.style_columns)

vol_ma = avg_method == "SMA" ? ta.sma(agg_vol,ma_len) : avg_method == "EMA"? ta.ema(agg_vol,ma_len) : avg_method == "HMA"? ta.hma(agg_vol,ma_len) : 0
plot(vol_mult * vol_ma,"MA",chart.bg_color == color.white ? color.black : color.white)

if agg_vol > vol_mult * vol_ma
    label.new(bar_index,agg_vol,str.tostring(int(agg_vol),format.volume),textcolor = color.white,size = size.tiny)