本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org
// © JoshBowler
//@version=6
indicator("Pre-1914 Hard Asset Basket Ratio [Automated Bands]", overlay=false)
// 1. Fetch the Core Commodities (Using continuous futures for deep history)
gold = request.security("COMEX:GC1!", timeframe.period, close)
silver = request.security("COMEX:SI1!", timeframe.period, close)
oil = request.security("NYMEX:BZ1!", timeframe.period, close) // Brent Crude
wheat = request.security("CBOT:ZW1!", timeframe.period, close) / 100 // Convert cents to dollars
copper = request.security("COMEX:HG1!", timeframe.period, close) // Priced per lb
// 2. Equal-Weight Commodity Basket Index Calculation
basketIndex = (oil * 1.5) + (wheat * 15) + (copper * 300)
// 3. Calculate how many "Baskets" an ounce of Gold or Silver buys
goldToBasket = gold / basketIndex
silverToBasket = (silver / basketIndex) * 50 // Scaled x50 for direct visual comparison
// 4. Automated Band Calculation (Multi-decade Volatility Channels)
lookbackLength = 200
stdDevMultiplier = 2.0
goldBasis = ta.sma(goldToBasket, lookbackLength)
goldDev = stdDevMultiplier * ta.stdev(goldToBasket, lookbackLength)
goldUpper = goldBasis + goldDev
goldLower = goldBasis - goldDev
// 5. Plot the Asset Lines
plot(goldToBasket, title="Gold Line", color=#FFD700, linewidth=2)
plot(silverToBasket, title="Silver Line (Scaled x50)", color=#C0C0C0, linewidth=2)
// 6. Plot the Dynamic Boundaries (Fixed using universal plot.style_line compatibility)
plot(goldBasis, title="Macro Mean Centerline", color=color.new(color.blue, 40), linewidth=1, style=plot.style_line)
plot(goldUpper, title="Gold Upper Target (Take Profit Zone)", color=color.new(color.red, 30), linewidth=1, style=plot.style_line)
plot(goldLower, title="Gold Lower Target (Accumulation Zone)", color=color.new(color.green, 30), linewidth=1, style=plot.style_line)