Bitcoin Relative Value Indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bigcitytom

//@version=5
indicator(title='Bitcoin Trend Analysis', shorttitle='BTC Analysis', overlay=true)

// Define the symbols for Bitcoin, DXY, CPI, M2 money supply, and the total US stock market
btc_symbol = 'COINBASE:BTCUSD'
dxy_symbol = 'DXY'
cpi_symbol = 'FRED/CPIAUCSL'
m2_symbol = 'FRED/M2SL'
us_stock_symbol = 'NYSE'

// Get the close price data for Bitcoin, DXY, CPI, M2 money supply, and the total US stock market
btc_close = request.security(btc_symbol, timeframe.period, close)
dxy_close = request.security(dxy_symbol, timeframe.period, close)
cpi_close = request.security(cpi_symbol, timeframe.period, close)
m2_close = request.security(m2_symbol, timeframe.period, close)
us_stock_close = request.security(us_stock_symbol, timeframe.period, close)

// Calculate the average of DXY, CPI, M2 money supply, and the total US stock market
average_close = (dxy_close + cpi_close + m2_close + us_stock_close) / 4

// Determine if Bitcoin is increasing or decreasing in value relative to the average of the four data points
trend = btc_close > average_close ? 1 : btc_close < average_close ? -1 : 0

// Plot the trend on the chart using green and red circles
plotshape(trend == 1 ? btc_close : na, style=shape.circle, location=location.abovebar, color=color.new(color.green, 0), size=size.large, title='Bitcoin Increasing in Value')
plotshape(trend == -1 ? btc_close : na, style=shape.circle, location=location.abovebar, color=color.new(color.red, 0), size=size.large, title='Bitcoin Decreasing in Value')

