Why Correlations Matter
Gold does not move in isolation. It has well-known relationships with the US dollar, Treasury yields, and risk sentiment. Understanding these correlations lets you use one market's behavior to anticipate another's, confirm signals, and avoid overexposure to correlated positions.
Gold vs USD (DXY)
Typically inverse correlation (-0.7 to -0.9). When the dollar strengthens, gold tends to fall, and vice versa.
Gold vs AUDUSD
Positive correlation (+0.5 to +0.8). Australia is a major gold producer, so AUD often follows gold.
Gold vs USDJPY
Weakly inverse. Both gold and JPY are safe-haven assets, so they tend to rise during risk-off events.
Gold vs EURUSD
Moderately positive (+0.3 to +0.6). Both tend to benefit from USD weakness.
Building a Correlation Tracker
We will fetch OHLCV data for multiple symbols and calculate rolling correlations:
import requests
import numpy as np
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://tickatlas.com/v1"
def fetch_closes(symbol: str, timeframe: str, limit: int = 50) -> list[float]:
"""Fetch closing prices for correlation calculation."""
resp = requests.get(
f"{BASE_URL}/ohlc",
headers={"X-API-Key": API_KEY},
params={"symbol": symbol, "timeframe": timeframe, "limit": limit},
)
resp.raise_for_status()
candles = resp.json()["data"]["candles"]
return [c["close"] for c in candles]
def calculate_correlation(closes_a: list, closes_b: list) -> float:
"""Pearson correlation coefficient between two price series."""
if len(closes_a) != len(closes_b):
min_len = min(len(closes_a), len(closes_b))
closes_a = closes_a[:min_len]
closes_b = closes_b[:min_len]
return round(float(np.corrcoef(closes_a, closes_b)[0, 1]), 3)
# Calculate correlations
gold = fetch_closes("XAUUSD", "D1", 50)
pairs = {
"EURUSD": fetch_closes("EURUSD", "D1", 50),
"GBPUSD": fetch_closes("GBPUSD", "D1", 50),
"AUDUSD": fetch_closes("AUDUSD", "D1", 50),
"USDJPY": fetch_closes("USDJPY", "D1", 50),
"USDCAD": fetch_closes("USDCAD", "D1", 50),
}
print("Gold (XAUUSD) Correlations -- 50-Day Rolling:")
for pair, closes in pairs.items():
corr = calculate_correlation(gold, closes)
print(f" {pair}: {corr:+.3f}") Typical output:
Gold (XAUUSD) Correlations -- 50-Day Rolling:
EURUSD: +0.647
GBPUSD: +0.512
AUDUSD: +0.734
USDJPY: -0.421
USDCAD: -0.583 Trading the Divergences
The most valuable trading signals come when a correlation breaks down temporarily. If gold rallies but AUDUSD fails to follow, one of them is "wrong" and likely to catch up.
def detect_divergence(
sym_a: str, sym_b: str, timeframe: str,
expected_correlation: float, threshold: float = 0.3
) -> dict:
"""Detect when two normally-correlated assets diverge."""
# Get RSI for both (as a proxy for recent momentum)
rsi_a = requests.get(
f"{BASE_URL}/indicator", headers={"X-API-Key": API_KEY},
params={"symbol": sym_a, "indicator": "RSI_14", "timeframe": timeframe},
).json()["data"]["value"]
rsi_b = requests.get(
f"{BASE_URL}/indicator", headers={"X-API-Key": API_KEY},
params={"symbol": sym_b, "indicator": "RSI_14", "timeframe": timeframe},
).json()["data"]["value"]
# Normalize RSI to -1 to +1 scale
norm_a = (rsi_a - 50) / 50
norm_b = (rsi_b - 50) / 50
if expected_correlation > 0:
# Positive correlation: both should move same direction
divergence = abs(norm_a - norm_b)
else:
# Negative correlation: should move opposite
divergence = abs(norm_a + norm_b)
return {
"pair_a": f"{sym_a} (RSI: {rsi_a:.1f})",
"pair_b": f"{sym_b} (RSI: {rsi_b:.1f})",
"divergence_score": round(divergence, 2),
"is_divergent": divergence > threshold,
}
# Check if gold and AUDUSD are diverging
result = detect_divergence("XAUUSD", "AUDUSD", "D1", expected_correlation=0.7)
if result["is_divergent"]:
print(f"DIVERGENCE: {result['pair_a']} vs {result['pair_b']}")
print(f"Score: {result['divergence_score']}") Practical Applications
Confirmation filter
Before going long on AUDUSD, check if gold is also showing bullish indicators. If gold is bearish, the AUDUSD long signal is weaker.
Portfolio hedging
If you are long XAUUSD and long AUDUSD, you have double exposure to gold sentiment. Use correlation data to avoid unintended concentration.
Mean reversion pairs
When highly correlated pairs diverge, bet on convergence. Go long the underperformer and short the outperformer for a market-neutral trade.
Run this against live data.
Every account starts pay-as-you-go with $2.50 of credit and no card. Paste the key into the samples above and the requests work unchanged.