The Price of Hard Money
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © capriole_charles

//@version=5
indicator("The Price of Hard Money",overlay=true)

output    = input.string("Hard Money Price (in Gold)", options=["Hard Money Price (in Gold)", "Hard Money Price (in Bitcoin)", "Hard Money Mcap", "Gold Mcap"])

// DATA

gld       = request.security("TVC:GOLD",timeframe.period,close)
btc       = request.security("BNC:BLX",timeframe.period,close)
btc_mcap  = request.security("CRYPTOCAP:BTC",timeframe.period,close)

// INPUTS FOR TODAY:  https://www.google.com/search?q=gold+market+cap&oq=gold+market+cap

today_gld_mcap      = 12.127*1000000000000
today_gld_price     = 1838
today               = timestamp(2022, 12, 28, 00, 00)
inf                 = 0.017 // inflation rate of gold: https://www.cmegroup.com/insights/economic-research/2022/goldsilver-the-understated-importance-of-supply.html

// CALCULATE GOLD MCAP

days_since_data     = (time - today)/(60*60*24*1000*1440/timeframe.multiplier)
units_of_gold       = (today_gld_mcap/today_gld_price) * math.pow(1+inf,days_since_data/365)
est_gld_mcap        = units_of_gold * gld

// HARD MONEY = Gold + Bitcoin

hm_mcap             = est_gld_mcap + btc_mcap
hm_price_in_gld     = hm_mcap / units_of_gold
units_of_btc        = btc_mcap/btc
hm_price_in_btc     = hm_mcap / units_of_btc

plot =output=="Hard Money Mcap"                   ? hm_mcap :
      output=="Hard Money Price (in Gold)"        ? hm_price_in_gld : 
      output=="Hard Money Price (in Bitcoin)"     ? hm_price_in_btc : 
      output=="Gold Mcap"                         ? est_gld_mcap : na

plot(plot, linewidth = 2)

// Sourcing
var table_source = table(na)
table_source := table.new(position=position.bottom_left, columns=1, rows=1, bgcolor=color.white, border_width=1)
table.cell(table_source, 0, 0, text="Source: Capriole Investments Limited", bgcolor=color.white, text_color=color.black, width=20, height=7, text_size=size.normal, text_halign=text.align_left)