OPEN-SOURCE SCRIPT
MVRV-Z For Loop

🧠 Overview
MVRV-Z For Loop is a trend-following indicator that applies a custom directional for-loop logic to the MVRV Z-score. By evaluating the number of consecutive Z-score improvements or deteriorations over time, it identifies sustained directional pressure in Bitcoin’s on-chain trend — helping traders align with prevailing market strength rather than reacting to single-point extremes.
🧩 Key Features
🔍 How It Works
Signal Logic:
🔁 Use Cases & Applications
✅ Conclusion
MVRV-Z For Loop transforms the traditional MVRV Z-score into a trend-following signal using a cumulative scoring approach. It excels in highlighting sustained directional strength and avoids premature entries during valuation whipsaws. This makes it a strong tool for traders looking to stay on the right side of the trend without overreacting to short-term fluctuations.
⚠️ Disclaimer
The content provided by this indicator is for educational and informational purposes only. Nothing herein constitutes financial or investment advice. Trading and investing involve risk, including the potential loss of capital. Always backtest and apply risk management suited to your strategy.
MVRV-Z For Loop is a trend-following indicator that applies a custom directional for-loop logic to the MVRV Z-score. By evaluating the number of consecutive Z-score improvements or deteriorations over time, it identifies sustained directional pressure in Bitcoin’s on-chain trend — helping traders align with prevailing market strength rather than reacting to single-point extremes.
🧩 Key Features
- Loop-Based Trend Filter: Applies a running comparison loop to assess whether MVRV-Z has been consistently strengthening or weakening.
- Directional Scoring System: Each upward movement contributes positively, and each downward movement negatively, producing a cumulative trend score.
- Z-Scored MVRV: Leverages on-chain valuation via the Market Cap to Realized Cap ratio, normalized using a long-term rolling average and standard deviation.
- Custom Thresholds: User-defined thresholds for long and short signals based on trend score magnitude.
- Dynamic Candle Coloring: Visually reinforces trend state with aqua for bullish and red for bearish environments.
🔍 How It Works
- Z-score Transformation: The MVRV ratio is normalized over a long lookback (default 1050 days), creating a standardized valuation signal.
- For-Loop Engine: A directional loop compares the current MVRV-Z value to previous values within a defined range (start to end).
- If today’s value is higher than ma, it adds +1 to the score; otherwise, it subtracts -1.
*This loop effectively measures momentum consistency rather than magnitude alone.
Signal Logic:
- A Long signal is triggered when the cumulative trend score exceeds the long_threshold.
- A Short signal is triggered when the score drops below the short_threshold.
- State Variable (CD): Tracks the market regime (1 = long, -1 = short), updating only when a valid condition is met.
🔁 Use Cases & Applications
- Trend Confirmation Tool: Helps traders assess whether a directional move has been sustained over time before committing.
- Momentum Alignment: Filters out short-term noise by scoring consistency in MVRV-Z movement rather than relying on single-bar reversals.
- Best Suited for BTC: This indicator is specifically built using Bitcoin’s Market Cap and Realized Cap metrics, making it ideal for BTC trend tracking.
✅ Conclusion
MVRV-Z For Loop transforms the traditional MVRV Z-score into a trend-following signal using a cumulative scoring approach. It excels in highlighting sustained directional strength and avoids premature entries during valuation whipsaws. This makes it a strong tool for traders looking to stay on the right side of the trend without overreacting to short-term fluctuations.
⚠️ Disclaimer
The content provided by this indicator is for educational and informational purposes only. Nothing herein constitutes financial or investment advice. Trading and investing involve risk, including the potential loss of capital. Always backtest and apply risk management suited to your strategy.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.