Reserve Balances with Federal Reserve Banks
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Quang47


//@version=5
indicator("Reserve Balances with Federal Reserve Banks", overlay=true, scale=scale.right)

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

unit_input = input.string('Millions', options=['Millions', 'Billions', 'Trillions'])
units = unit_input == 'Billions' ? 1e3 : unit_input == 'Millions' ? 1e0 : unit_input == 'Trillions' ? 1e6 : na
fed_res = request.security('FRED:WRESBAL', i_res, close) // millions


fed_out = fed_res  / units

var fed_res_offset = 0 // 2-week offset for use with daily charts

if timeframe.isdaily
    fed_res_offset := 0

if timeframe.isweekly
    fed_res_offset := 0
    
if timeframe.ismonthly
    fed_res_offset := 0
    
plot(fed_out, title='Reserve Balances', color=color.new(color.yellow,0), style=plot.style_line, linewidth=4, offset=fed_res_offset)
