OPEN-SOURCE SCRIPT

FEDFUNDS Rate Divergence Oscillator [BackQuant]

665
FEDFUNDS Rate Divergence Oscillator [BackQuant]

1. Concept and Rationale
The United States Federal Funds Rate is the anchor around which global dollar liquidity and risk-free yield expectations revolve. When the Fed hikes, borrowing costs rise, liquidity tightens and most risk assets encounter head-winds. When it cuts, liquidity expands, speculative appetite often recovers. Bitcoin, a 24-hour permissionless asset sometimes described as “digital gold with venture-capital-like convexity,” is particularly sensitive to macro-liquidity swings.
The FED Divergence Oscillator quantifies the behavioural gap between short-term monetary policy (proxied by the effective Fed Funds Rate) and Bitcoin’s own percentage price change. By converting each series into identical rate-of-change units, subtracting them, then optionally smoothing the result, the script produces a single bounded-yet-dynamic line that tells you, at a glance, whether Bitcoin is outperforming or underperforming the policy backdrop—and by how much.

2. Data Pipeline
Fed Funds Rate – Pulled directly from the FRED database via the ticker “FRED:FEDFUNDS,” sampled at daily frequency to synchronise with crypto closes.
Bitcoin Price – By default the script forces a daily timeframe so that both series share time alignment, although you can disable that and plot the oscillator on intraday charts if you prefer.
User Source Flexibility – The BTC series is not hard-wired; you can select any exchange-specific symbol or even swap BTC for another crypto or risk asset whose interaction with the Fed rate you wish to study.

3. Math under the Hood
(1) Rate of Change (ROC) – Both the Fed rate and BTC close are converted to percent return over a user-chosen lookback (default 30 bars). This means a cut from 5.25 percent to 5.00 percent feeds in as –4.76 percent, while a climb from 25 000 to 30 000 USD in BTC over the same window converts to +20 percent.
(2) Divergence Construction – The script subtracts the Fed ROC from the BTC ROC. Positive values show BTC appreciating faster than policy is tightening (or falling slower than the rate is cutting); negative values show the opposite.
(3) Optional Smoothing – Macro series are noisy. Toggle “Apply Smoothing” to calm the line with your preferred moving-average flavour: SMA, EMA, DEMA, TEMA, RMA, WMA or Hull. The default EMA-25 removes day-to-day whips while keeping turning points alive.
(4) Dynamic Colour Mapping – Rather than using a single hue, the oscillator line employs a gradient where deep greens represent strong bullish divergence and dark reds flag sharp bearish divergence. This heat-map approach lets you gauge intensity without squinting at numbers.
(5) Threshold Grid – Five horizontal guides create a structured regime map:
 • Lower Extreme (–50 pct) and Upper Extreme (+50 pct) identify panic capitulations and euphoria blow-offs.
 • Oversold (–20 pct) and Overbought (+20 pct) act as early warning alarms.
 • Zero Line demarcates neutral alignment.

4. Chart Furniture and User Interface
• Oscillator fill with a secondary DEMA-30 “shader” offers depth perception: fat ribbons often precede high-volatility macro shifts.
• Optional bar-colouring paints candles green when the oscillator is above zero and red below, handy for visual correlation.
• Background tints when the line breaches extreme zones, making macro inflection weeks pop out in the replay bar.
• Everything—line width, thresholds, colours—can be customised so the indicator blends into any template.

5. Interpretation Guide

Macro Liquidity Pulse
 • When the oscillator spends weeks above +20 while the Fed is still raising rates, Bitcoin is signalling liquidity tolerance or an anticipatory pivot view. That condition often marks the embryonic phase of major bull cycles (e.g., March 2020 rebound).
 • Sustained prints below –20 while the Fed is already dovish indicate risk aversion or idiosyncratic crypto stress—think exchange scandals or broad flight to safety.

Regime Transition Signals
 • Bullish cross through zero after a long sub-zero stint shows Bitcoin regaining upward escape velocity versus policy.
 • Bearish cross under zero during a hiking cycle tells you monetary tightening has finally started to bite.

Momentum Exhaustion and Mean-Reversion
 • Touches of +50 (or –50) come rarely; they are statistically stretched events. Fade strategies either taking profits or hedging have historically enjoyed positive expectancy.
 • Inside-bar candlestick patterns or lower-timeframe bearish engulfings simultaneously with an extreme overbought print make high-probability short scalp setups, especially near weekly resistance. The same logic mirrors for oversold.

Pair Trading / Relative Value
 • Combine the oscillator with spreads like BTC versus Nasdaq 100. When both the FED Divergence oscillator and the BTC–NDQ relative-strength line roll south together, the cross-asset confirmation amplifies conviction in a mean-reversion short.
 • Swap BTC for miners, altcoins or high-beta equities to test who is the divergence leader.

Event-Driven Tactics
 • FOMC days: plot the oscillator on an hourly chart (disable ‘Force Daily TF’). Watch for micro-structural spikes that resolve in the first hour after the statement; rapid flips across zero can front-run post-FOMC swings.
 • CPI and NFP prints: extremes reached into the release often mean positioning is one-sided. A reversion toward neutral in the first 24 hours is common.

6. Alerts Suite
Pre-bundled conditions let you automate workflows:
• Bullish / Bearish zero crosses – queue spot or futures entries.
• Standard OB / OS – notify for first contact with actionable zones.
• Extreme OB / OS – prime time to review hedges, take profits or build contrarian swing positions.

7. Parameter Playground
• Shorten ROC Lookback to 14 for tactical traders; lengthen to 90 for macro investors.
• Raise extreme thresholds (for example ±80) when plotting on altcoins that exhibit higher volatility than BTC.
• Try HMA smoothing for responsive yet smooth curves on intraday charts.
• Colour-blind users can easily swap bull and bear palette selections for preferred contrasts.

8. Limitations and Best Practices
• The Fed Funds series is step-wise; it only changes on meeting days. Rapid BTC oscillations in between may dominate the calculation. Keep that perspective when interpreting very high-frequency signals.
• Divergence does not equal causation. Crypto-native catalysts (ETF approvals, hack headlines) can overwhelm macro links temporarily.
• Use in conjunction with classical confirmation tools—order-flow footprints, market-profile ledges, or simple price action to avoid “pure-indicator” traps.

9. Final Thoughts
The FEDFUNDS Rate Divergence Oscillator distills an entire macro narrative monetary policy versus risk sentiment into a single colourful heartbeat. It will not magically predict every pivot, yet it excels at framing market context, spotting stretches and timing regime changes. Treat it as a strategic compass rather than a tactical sniper scope, combine it with sound risk management and multi-factor confirmation, and you will possess a robust edge anchored in the world’s most influential interest-rate benchmark.

Trade consciously, stay adaptive, and let the policy-price tension guide your roadmap.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.