OPEN-SOURCE SCRIPT

BTC/Gold Ratio - CriptoMatiko

488
The BTC/Gold Ratio plots the ratio between Bitcoin (BTCUSD) and Gold (XAUUSD) prices — expressing Bitcoin's value in terms of gold ounces over time. Beyond the raw ratio, this script adds two analytical layers that most ratio plots omit.

─────────────────────────────────────────────
ANALYTICAL LAYERS
─────────────────────────────────────────────

**1. Days since last peak counter**

The script tracks how many calendar days have elapsed since the ratio last set a new all-time high. The counter resets only when the ratio makes a new peak. This measurement is relevant because Bitcoin's ratio against gold has historically entered extended consolidation phases after each cycle peak, and the length of those phases has been broadly consistent across cycles.

**2. Historical bounce zone**

Based on previous cycle data, the ratio has historically found support and reversed upward approximately 390 days after each major peak. The script highlights this zone with a green background and displays a label on the last bar when the day counter enters the configured range. The threshold is fully adjustable.

When both conditions are true (you are inside the bounce zone), the chart background turns green and a label appears showing the exact number of days since the peak.

─────────────────────────────────────────────
DATA SOURCE
─────────────────────────────────────────────

Both BTCUSD and XAUUSD are always fetched on the daily ("D") timeframe, regardless of the chart's active timeframe. This design choice avoids the heavy processing cost of loading intraday ticks for two separate assets and ensures the ratio is always based on daily reference prices — the standard for cycle analysis.

─────────────────────────────────────────────
VISUAL OUTPUTS
─────────────────────────────────────────────

- Main plot: BTC/Gold ratio (teal line)
- Optional EMA of the ratio (orange line) — configurable period, useful as a trend reference
- Green background when the day counter is inside the bounce zone
- Label on the last bar: shows days since peak (visible only when inside the bounce zone)
- Info table (top right):
- Current Ratio: latest ratio value
- Days Since Peak: counter in calendar days
- Bounce Zone: Active (green) or Waiting (yellow)

─────────────────────────────────────────────
INPUTS
─────────────────────────────────────────────

Settings:
- EMA Period: period for the ratio EMA (default 100, range 50–500)
- Days since peak → bounce zone: day threshold to activate the bounce zone highlight (default 390, range 100–700)

Visual:
- Show EMA: toggle EMA line on/off
- Highlight historical bounce zone: toggle green background on/off

─────────────────────────────────────────────
ALERTS
─────────────────────────────────────────────

- "Bounce zone reached": fires once when the day counter hits the configured threshold
- "Ratio crossed above EMA": fires on EMA crossover (potential trend reversal confirmation)

─────────────────────────────────────────────
RECOMMENDED USAGE
─────────────────────────────────────────────

Apply to any chart — the ratio is always computed from daily BTCUSD and XAUUSD data regardless of chart timeframe. Recommended: view on a Daily (1D) chart for cleaner visual alignment with the ratio's native resolution.

─────────────────────────────────────────────
CHART ANNOTATIONS
─────────────────────────────────────────────

The publication chart includes manual drawings to illustrate the historical cycle data described above. The blue horizontal arrows with "395 bars / 395d" labels mark the measured duration between the ratio's last two major peaks and their respective bounce zones — showing that both cycles lasted approximately 395 days. The red descending arrows mark the peak-to-trough trajectory of the ratio in each cycle. These drawings are included to help readers visually connect the script's bounce zone logic to the actual historical data.

For educational purposes only. Not financial advice.

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.