Bitcoin to GOLD [presentTrading]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PresentTrading

//@version=5
indicator('Bitcoin to GOLD [presentTrading]')

TimeFrame = input.string('480', "Time Frame")
ma_length = input.int(200, 'Moving Average Length')

// Changed from Gold to Bitcoin
BTC = request.security('BINANCE:BTCUSD', TimeFrame, close)
GOLD = request.security('TVC:SPX', TimeFrame, close)
BTGRatio = BTC / GOLD
BTGRatio_ma = ta.sma(BTGRatio, ma_length)
BTGRatio_std = ta.stdev(BTGRatio, ma_length)

// Calculate the upper and lower bands
upper_band = BTGRatio_ma + BTGRatio_std
lower_band = BTGRatio_ma - BTGRatio_std

// Plotting
p = plot(BTGRatio, linewidth=2)
ma = plot(BTGRatio_ma, color=color.new(#3179f5, 0), linewidth=2)
plot(upper_band, color=color.new(#3179f5, 0), linewidth=2)
plot(lower_band, color=color.new(#3179f5, 0), linewidth=2)
fill(p, ma, color=BTGRatio > BTGRatio_ma ? color.red: color.teal, transp=15)



