OPEN-SOURCE SCRIPT

Bitcoin vs Inverted DXY Regime | Astral Vision

301
Bitcoin vs Inverted DXY Regime | Astral Vision 🌠💠

Inspired by: JackGreenCrypto

This indicator plots the Z-Score of Bitcoin's log price and the inverted Z-Score of the DXY Dollar Index on the same scale, shifted forward in time by a configurable lag, to visualize the historical inverse relationship between dollar strength and Bitcoin price and to identify divergences between the two series before they resolve in price.

Calculation ⚙️

Both Bitcoin and DXY are first transformed by taking their natural logarithm. Working in log space is essential for two reasons: Bitcoin has moved across several orders of magnitude, so raw price differences between 2015 and 2024 are not comparable; and the inverse relationship between DXY and Bitcoin is proportional rather than linear, meaning a 10% move in DXY has a proportionally similar impact regardless of absolute price level.

The Z-Score is then computed independently for each series using the same formula: subtract the simple moving average of the log series over the lookback window from the current log value, then divide by the standard deviation of the same window. The result for each series is: Z = (log(price) - SMA(log(price), N)) / StDev(log(price), N), where N is the configurable Z-Score lookback. This expresses each series in units of standard deviations above or below its own rolling mean, making the two series directly comparable on the same scale regardless of their absolute price differences.

The DXY Z-Score is then multiplied by -1 to invert it. Since DXY and Bitcoin historically move in opposite directions, the uninverted DXY Z-Score would mirror Bitcoin rather than track it. After inversion, the two series should theoretically overlap or move together during periods of normal inverse correlation. Divergences, where Bitcoin's Z-Score moves in one direction while the inverted DXY Z-Score moves in the other, signal a breakdown in the typical relationship that has historically tended to resolve by one series catching up to the other.

The inverted DXY line is plotted with a configurable forward offset in bars. This operationalizes the observed lag between dollar index movements and their full transmission into Bitcoin price, allowing the DXY signal to be read as a leading indicator rather than a coincident one.

Plots 📊
  • Bitcoin log Z-Score over the configurable lookback window
  • Inverted DXY log Z-Score shifted forward by the configurable lag


Inputs 🎛️
  • Z-Score Lookback: rolling window for mean and standard deviation applied to both series
  • DXY Lag: bars to shift the inverted DXY signal forward in time


Colors 🎨
5 Astral Vision presets + custom override. Default: Paradiso.

Purpose 🎯
Standard correlation tools between Bitcoin and DXY operate on raw prices or percentage returns, which are distorted by the enormous scale difference between the two assets and by Bitcoin's exponential growth trend. Computing both in log space and normalizing via Z-Score removes these distortions entirely, placing both series on equal statistical footing. The forward shift on the DXY line turns a coincident correlation chart into a directional leading signal: when the inverted DXY is rising ahead of Bitcoin's Z-Score, it suggests dollar weakness is building that has not yet fully priced into Bitcoin, and vice versa.

Disclaimer ⭕️
This indicator is for informational and educational purposes only. It does not constitute financial advice. Past performance is not indicative of future results. Always do your own research before making investment decisions.

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.