OPEN-SOURCE SCRIPT
Gold Mining Margin MACRO

Gold Mining Margin Macro Indicator — Description
This indicator measures the structural profitability of gold mining by comparing the gold price with estimated production costs. It is designed as a macro-context tool, not a short-term trading signal.
The script tracks three core components:
Gold − AISC (All-In Sustaining Cost) → proxy for mining profitability
Energy-adjusted mining margin → incorporates oil as a major production cost input
Gold / Oil ratio → intermarket relationship between gold and energy costs
Together, these metrics help visualize the economic pressure or expansion phase of the gold mining sector.
What the indicator measures
The indicator estimates whether gold is trading:
near production-cost pressure levels
in a neutral profitability zone
in a strong mining-profit environment
or in a boom phase
A weekly regime classification is used to reduce noise and focus on macro-cycle conditions rather than short-term price fluctuations.
Primary use case
This indicator is intended to help identify:
potential gold price floor zones
mining-sector stress conditions
cyclical turning points in gold
confirmation context for cycle-based analysis
It works best when combined with:
cycle analysis
intermarket analysis
positioning data
macroeconomic context
Important note
The AISC value is user-defined and represents an approximate global industry cost level, not the cost of a specific mining company.
The indicator is meant to reflect sector-level economics, not individual equities.
This indicator measures the structural profitability of gold mining by comparing the gold price with estimated production costs. It is designed as a macro-context tool, not a short-term trading signal.
The script tracks three core components:
Gold − AISC (All-In Sustaining Cost) → proxy for mining profitability
Energy-adjusted mining margin → incorporates oil as a major production cost input
Gold / Oil ratio → intermarket relationship between gold and energy costs
Together, these metrics help visualize the economic pressure or expansion phase of the gold mining sector.
What the indicator measures
The indicator estimates whether gold is trading:
near production-cost pressure levels
in a neutral profitability zone
in a strong mining-profit environment
or in a boom phase
A weekly regime classification is used to reduce noise and focus on macro-cycle conditions rather than short-term price fluctuations.
Primary use case
This indicator is intended to help identify:
potential gold price floor zones
mining-sector stress conditions
cyclical turning points in gold
confirmation context for cycle-based analysis
It works best when combined with:
cycle analysis
intermarket analysis
positioning data
macroeconomic context
Important note
The AISC value is user-defined and represents an approximate global industry cost level, not the cost of a specific mining company.
The indicator is meant to reflect sector-level economics, not individual equities.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.