OPEN-SOURCE SCRIPT
Gold/Silver Ratio with Supply Zones

Gold/Silver Ratio with Supply Zones
Overview
Key Features
Trading Applications
Default Settings
How to Interpret
Signal Logic
Visual Elements
Best Practices
Customization Options
Alert Conditions
Who This Is For
Important Notes
Data Sources
Overview
- Professional-grade indicator that tracks the Gold/Silver Ratio in real-time
- Identifies potential market imbalances and rotation opportunities between precious metals
- Features customizable threshold bands, moving averages, and automated trading signals
- Built on Pine Script v6 for maximum stability and performance
Key Features
- Real-Time Ratio Calculation: Automatically calculates Gold/Silver ratio using OANDA:XAUUSD and OANDA:XAGUSD price feeds
- Dynamic Threshold Zones: Visual bands showing when silver or gold may be undervalued relative to each other
- Moving Average Overlay: 20-period SMA to identify trend direction and momentum
- Automated Buy Signals: Triangle markers appear when ratio reaches extreme levels
- Live Information Table: Displays current ratio, moving average, individual metal prices, and market interpretation
- Custom Alerts: Set notifications when ratio crosses your defined thresholds
- Color-Coded Zones: Green zones indicate gold undervaluation, red zones indicate silver undervaluation
Trading Applications
- Mean Reversion Strategy: Enter silver positions when ratio exceeds 90, enter gold when ratio falls below 70
- Rotation Trading: Switch between metals based on relative value signals
- Portfolio Rebalancing: Identify optimal times to adjust precious metals allocation
- Divergence Analysis: Compare ratio behavior against individual metal price action
Default Settings
- High Threshold: 90.0 (Silver undervalued zone)
- Low Threshold: 70.0 (Gold undervalued zone)
- Moving Average: 20-period SMA
- Historical Reference: 80:1 ratio marked as long-term mean
How to Interpret
- Ratio Above 90: Silver is undervalued relative to gold - consider increasing silver exposure
- Ratio Below 70: Gold is undervalued relative to silver - consider increasing gold exposure
- Ratio Between 70-90: Neutral range - no clear relative value advantage
- Rising Ratio: Gold outperforming silver
- Falling Ratio: Silver outperforming gold
Signal Logic
- Green Triangle (Bottom): Ratio crosses above high threshold → Buy Silver Signal
- Red Triangle (Top): Ratio crosses below low threshold → Buy Gold Signal
- MA Crossovers: Use 20-period MA for trend confirmation and entry timing
Visual Elements
- Blue Line: Current gold/silver ratio value
- Orange Line: 20-period moving average smoothing
- Red Shaded Zone: Area where gold is relatively expensive
- Green Shaded Zone: Area where gold is relatively cheap
- Gray Dotted Line: Historical mean at 80:1
- Info Table: Real-time statistics and market interpretation
Best Practices
- Use on daily timeframe or higher for most reliable signals
- Combine with volume analysis and individual metal technicals
- Monitor Federal Reserve policy and USD strength as macro context
- Consider industrial demand factors for silver (solar, EV, electronics)
- Watch safe-haven flows during economic uncertainty for gold
Customization Options
- Adjust threshold levels based on your preferred lookback period
- Modify moving average length to suit your trading timeframe
- Toggle bands on/off for cleaner chart visualization
- Change data source tickers if using different brokers (FXCM, FOREXCOM, etc.)
Alert Conditions
- Silver Undervalued Alert: Triggers when ratio crosses above your high threshold
- Gold Undervalued Alert: Triggers when ratio crosses below your low threshold
- Receive notifications via TradingView mobile app, email, or webhook
Who This Is For
- Precious metals traders seeking relative value opportunities
- Portfolio managers balancing gold and silver allocations
- Macro traders using metals as inflation hedges
- Swing traders capitalizing on mean reversion patterns
- Long-term investors optimizing entry points
Important Notes
- This indicator tracks price ratios, not physical supply data
- COMEX warehouse stocks are not directly available in TradingView
- Ratio analysis assumes historical mean reversion tendencies
- Always combine with fundamental analysis and risk management
- Past performance does not guarantee future results
Data Sources
- Gold Price: OANDA:XAUUSD (spot gold in US dollars)
- Silver Price: OANDA:XAGUSD (spot silver in US dollars)
- Update Frequency: Real-time during market hours
- Historical Data: Full TradingView historical coverage available
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.