Fed Net Liquidity Indicator v2
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jlb05013

//@version=5
indicator("Fed Net Liquidity Indicator", overlay=true)

i_res = input.timeframe('D', "Resolution", options=['D', 'W', 'M'])

fed_bal = request.security('FRED:WALCL', i_res, close)/1e9 // millions
tga = request.security('FRED:WTREGEN', i_res, close)/1e9 // billions
rev_repo = request.security('FRED:RRPONTSYD', i_res, close)/1e9 // billions

net_liquidity = (fed_bal - (tga + rev_repo)) / 1.1 - 1625

var net_liquidity_offset = 10 // 2-week offset for use with daily charts

if timeframe.isdaily
    net_liquidity_offset := 10

if timeframe.isweekly
    net_liquidity_offset := 2
    
if timeframe.ismonthly
    net_liquidity_offset := 0
    
plot(net_liquidity, title='Net Liquidity', color=color.new(color.blue, 80), style=plot.style_area, offset=net_liquidity_offset)
