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.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.