Volume
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © JanLosev
// I am Now a Millionaire. Thank you! Jan.
//@version=5
indicator(title="Volume", shorttitle="Volume", overlay=false, precision=2)

source = input.source(close, "Source")
length = input(28, "Length")

bof = input.bool(true,"Volume BTC")
eof = input.bool(false,"Volume ETH")

mab = input.bool(false,"EMA BTC")
mae = input.bool(false,"EMA ETH")

sumb = input.bool(false,"SUM BTC")
sume = input.bool(false,"SUM ETH")


/// BITCOIN FIAT
vBTC1 = request.security("BINANCEUS:BTCUSD", "", volume)
prBTC2= request.security("FTX:BTCUSD", "", source)
vBTC2 = request.security("FTX:BTCUSD", "", volume) / prBTC2
vBTC3 = request.security("COINBASE:BTCUSD", "", volume)
vBTC4 = request.security("KRAKEN:XBTUSD", "", volume)
vBTC5 = request.security("GEMINI:BTCUSD", "", volume)
vBTC6 = request.security("BITFINEX:BTCUSD", "", volume)
vBTC7 = request.security("BITSTAMP:BTCUSD", "", volume)

perVOLUMEbtc = vBTC1 + vBTC2 + vBTC3 + vBTC4 + vBTC5 + vBTC6 + vBTC7
colvolumeBTC = close > open  ? #1680d4:#ff001a
plot(bof?perVOLUMEbtc:na,"volumeBTC_DOLLAR", style=plot.style_histogram, linewidth=3, color=colvolumeBTC)

sumBTC_B = (close > open  ? math.sum(perVOLUMEbtc,length) : na) 
sumBTC_R = (close < open  ? math.sum(perVOLUMEbtc,length) : na)
emaBTC = ta.ema(perVOLUMEbtc,length)
plot(mab?emaBTC:na,"emaBTC",linewidth=1, color=#ffffff)

plot(sumb?sumBTC_B:na,"sumBTC_Blue",linewidth=1, color=#1680d4)
plot(sumb?sumBTC_R:na,"sumBTC_Red",linewidth=1, color=#ff001a)


/// ETHEREUM FIAT
vETH1 = request.security("BINANCEUS:ETHUSD", "", volume)
prETH2= request.security("FTX:ETHUSD", "", source)
vETH2 = request.security("FTX:ETHUSD", "", volume) / prETH2
vETH3 = request.security("COINBASE:ETHUSD", "", volume)
vETH4 = request.security("KRAKEN:ETHUSD", "", volume)
vETH5 = request.security("GEMINI:ETHUSD", "", volume)
vETH6 = request.security("BITFINEX:ETHUSD", "", volume)
vETH7 = request.security("BITSTAMP:ETHUSD", "", volume)

perVOLUMEeth = vETH1 + vETH2 + vETH3 + vETH4 + vETH5 + vETH6 + vETH7
colvolumeETH = close > open  ? #1680d4:#ff001a
plot(eof?perVOLUMEeth:na,"volumeETH_DOLLAR", style=plot.style_histogram, linewidth=3, color=colvolumeETH)

sumETH_B = (close > open  ? math.sum(perVOLUMEeth,length) : na) 
sumETH_R = (close < open  ? math.sum(perVOLUMEeth,length) : na)
emaETH = ta.ema(perVOLUMEeth,length)
plot(mae?emaETH:na,"emaETH",linewidth=1, color=#ffffff)

plot(sume?sumETH_B:na,"sumETH_Blue",linewidth=1, color=#1680d4)
plot(sume?sumETH_R:na,"sumETH_Red",linewidth=1, color=#ff001a)