Stablecoin supplies [USD bn]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tedtalksmacro

//@version=5
indicator("Crypto USD Liquidity [tedtalksmacro]")

usdt_supply = request.security("GLASSNODE:USDT_SUPPLY", 'D', close)
busd_supply = request.security("GLASSNODE:BUSD_SUPPLY", 'D', close)
usdc_supply = request.security("GLASSNODE:USDC_SUPPLY", 'D', close)
dai_supply = request.security("CRYPTOCAP:DAI", 'D', close)
tusd_supply = request.security("CRYPTOCAP:TUSD", 'D', close)


value = (usdt_supply + busd_supply + usdc_supply + dai_supply + tusd_supply) / 1000000000
var lineColor = true

ema20 = ta.ema(value, 20)

bullish = value > ema20
bearish = value < ema20

if lineColor
    if bearish
        lineColor := false
if not lineColor
    if bullish
        lineColor := true

// mycolor = higher ? color.silver : lower ? color.blue : na
supplyColor = lineColor ? color.rgb(101, 171, 103) : color.rgb(197, 10, 10)
plot(value, transp = 0, linewidth=2, color= supplyColor)