OPEN-SOURCE SCRIPT
Gold Oil Ratio

Gold Oil Ratio: Macro Sentiment & Mean Reversion Overlay
This indicator provides a sophisticated look at the Gold-to-Oil Ratio, one of the oldest and most reliable macro-economic barometers. By tracking the relative value between "Safe Haven" Gold and "Industrial Growth" Oil, traders can gauge global economic sentiment and potential market turning points.
Key Features:
Macro Barometer: Instantly see if the market is in a "Risk-Off" (high ratio) or "Risk-On" (low ratio) phase.
Adaptive Volatility Bands: Uses a custom-built volatility envelope (Mean + Standard Deviation) that adjusts to historical price action, highlighting extreme overbought or oversold conditions in the ratio.
Dynamic Gradient Visualization: The candle colors change dynamically based on where the ratio sits relative to its historical bands—shifting from green (undervalued/low) to red (overvalued/high).
The "2020 Precision Fix": Includes a specialized logic to handle the extreme negative oil price anomaly of April 2020, ensuring your charts remain readable and the bands don't get distorted by the "black swan" spike.
Inversion Toggle: Switch between Gold/Oil and Oil/Gold focus with a single click in the settings.
How to use it:
Mean Reversion: When the ratio touches the Upper Band (Red), Gold is historically expensive compared to Oil—watch for a potential reversal or macro shift.
Risk Sentiment: Crossing above the Mean Line often signals increasing global uncertainty, while staying below suggests industrial expansion and stable growth.
Divergence: Use the gradient candles to spot when the ratio is losing momentum at extreme levels before the price action confirms it.
Note: This script pulls data from COMEX:GC1! and NYMEX:CL1! to ensure the most accurate futures-based ratio calculation.
This indicator provides a sophisticated look at the Gold-to-Oil Ratio, one of the oldest and most reliable macro-economic barometers. By tracking the relative value between "Safe Haven" Gold and "Industrial Growth" Oil, traders can gauge global economic sentiment and potential market turning points.
Key Features:
Macro Barometer: Instantly see if the market is in a "Risk-Off" (high ratio) or "Risk-On" (low ratio) phase.
Adaptive Volatility Bands: Uses a custom-built volatility envelope (Mean + Standard Deviation) that adjusts to historical price action, highlighting extreme overbought or oversold conditions in the ratio.
Dynamic Gradient Visualization: The candle colors change dynamically based on where the ratio sits relative to its historical bands—shifting from green (undervalued/low) to red (overvalued/high).
The "2020 Precision Fix": Includes a specialized logic to handle the extreme negative oil price anomaly of April 2020, ensuring your charts remain readable and the bands don't get distorted by the "black swan" spike.
Inversion Toggle: Switch between Gold/Oil and Oil/Gold focus with a single click in the settings.
How to use it:
Mean Reversion: When the ratio touches the Upper Band (Red), Gold is historically expensive compared to Oil—watch for a potential reversal or macro shift.
Risk Sentiment: Crossing above the Mean Line often signals increasing global uncertainty, while staying below suggests industrial expansion and stable growth.
Divergence: Use the gradient candles to spot when the ratio is losing momentum at extreme levels before the price action confirms it.
Note: This script pulls data from COMEX:GC1! and NYMEX:CL1! to ensure the most accurate futures-based ratio calculation.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。