OPEN-SOURCE SCRIPT
Liquidity Index with Advanced Statistical Normalization

Liquidity Index with Advanced Statistical Normalization
An open-source TradingView indicator for analyzing global liquidity cycles using robust statistical methods
Overview
This Pine Script indicator combines multiple macroeconomic data sources to construct a composite liquidity index that tracks global financial conditions. It employs advanced statistical techniques typically found in quantitative finance research, adapted for real-time charting.
Key Features
📊 Multi-Source Data Integration
- Federal Reserve Components: Fed Funds Rate, Reverse Repo (RRP), Treasury General Account (TGA)
- PBOC Components: China M2 Money Stock adjusted by CNY/USD exchange rate
- Volatility Index: MOVE Index (bond market volatility)
🔬 Advanced Statistical Methods
1. Theil-Sen Estimator: Robust trend detection resistant to outliers
2. Triple Normalization:
- Z-score normalization
- MAD (Median Absolute Deviation) normalization
- Quantile normalization via inverse normal CDF
3. Multi-Timeframe Analysis: Short (8-bar) and long (34-bar) windows with blended composite
📈 Signal Processing
- Log-transformation for non-linear relationships
- Smoothing via customizable SMA
- Composite signal averaging across normalization methods
Why This Approach?
Traditional liquidity indicators often suffer from:
- Sensitivity to outliers in economic data
- Assumption of normal distributions
- Single-timeframe bias
This script addresses these issues by:
- Using median-based robust statistics (Theil-Sen, MAD)
- Applying multiple normalization techniques
- Blending short and long-term perspectives
Customization Options
short_length // Short window (default: 8)
long_length // Long window (default: 34)
show_short // Display short composite
show_long // Display long composite
show_blended // Display blended signal
smoothing_length // SMA smoothing period (default: 10)
How to Use
1. Liquidity Expansion (positive values): Risk-on environment, favorable for asset prices
2. Liquidity Contraction (negative values): Risk-off environment, potential market stress
3. Divergences: Compare indicator direction vs. price action for early warnings
Potential Improvements
Community members are encouraged to enhance:
- Additional data sources (ECB balance sheet, BOJ operations, etc.)
- Alternative normalization methods (robust scaling, rank transformation)
- Machine learning integration (LSTM forecasting, regime detection)
- Alert conditions for liquidity inflection points
- Volatility-adjusted weighting schemes
Technical Notes
- Uses request.security() for multi-symbol data fetching
- All calculations handle missing data via nz() functions
- Median-based statistics computed via array operations
- Custom inverse CDF approximation (no external libraries required)
Contributing
This is a foundation for liquidity analysis. Potential extensions:
- LLM Integration: Use language models to parse Fed/PBOC meeting minutes and adjust weights dynamically
- Sentiment Layer: Incorporate crypto funding rates or options skew
- Adaptive Parameters: Auto-tune window lengths based on market regime
- Cross-Asset Validation: Backtest signals against BTC, equities, bonds
---
License: Open source - modify and redistribute freelyDisclaimer: For educational purposes only. Not financial advice.
An open-source TradingView indicator for analyzing global liquidity cycles using robust statistical methods
Overview
This Pine Script indicator combines multiple macroeconomic data sources to construct a composite liquidity index that tracks global financial conditions. It employs advanced statistical techniques typically found in quantitative finance research, adapted for real-time charting.
Key Features
📊 Multi-Source Data Integration
- Federal Reserve Components: Fed Funds Rate, Reverse Repo (RRP), Treasury General Account (TGA)
- PBOC Components: China M2 Money Stock adjusted by CNY/USD exchange rate
- Volatility Index: MOVE Index (bond market volatility)
🔬 Advanced Statistical Methods
1. Theil-Sen Estimator: Robust trend detection resistant to outliers
2. Triple Normalization:
- Z-score normalization
- MAD (Median Absolute Deviation) normalization
- Quantile normalization via inverse normal CDF
3. Multi-Timeframe Analysis: Short (8-bar) and long (34-bar) windows with blended composite
📈 Signal Processing
- Log-transformation for non-linear relationships
- Smoothing via customizable SMA
- Composite signal averaging across normalization methods
Why This Approach?
Traditional liquidity indicators often suffer from:
- Sensitivity to outliers in economic data
- Assumption of normal distributions
- Single-timeframe bias
This script addresses these issues by:
- Using median-based robust statistics (Theil-Sen, MAD)
- Applying multiple normalization techniques
- Blending short and long-term perspectives
Customization Options
short_length // Short window (default: 8)
long_length // Long window (default: 34)
show_short // Display short composite
show_long // Display long composite
show_blended // Display blended signal
smoothing_length // SMA smoothing period (default: 10)
How to Use
1. Liquidity Expansion (positive values): Risk-on environment, favorable for asset prices
2. Liquidity Contraction (negative values): Risk-off environment, potential market stress
3. Divergences: Compare indicator direction vs. price action for early warnings
Potential Improvements
Community members are encouraged to enhance:
- Additional data sources (ECB balance sheet, BOJ operations, etc.)
- Alternative normalization methods (robust scaling, rank transformation)
- Machine learning integration (LSTM forecasting, regime detection)
- Alert conditions for liquidity inflection points
- Volatility-adjusted weighting schemes
Technical Notes
- Uses request.security() for multi-symbol data fetching
- All calculations handle missing data via nz() functions
- Median-based statistics computed via array operations
- Custom inverse CDF approximation (no external libraries required)
Contributing
This is a foundation for liquidity analysis. Potential extensions:
- LLM Integration: Use language models to parse Fed/PBOC meeting minutes and adjust weights dynamically
- Sentiment Layer: Incorporate crypto funding rates or options skew
- Adaptive Parameters: Auto-tune window lengths based on market regime
- Cross-Asset Validation: Backtest signals against BTC, equities, bonds
---
License: Open source - modify and redistribute freelyDisclaimer: For educational purposes only. Not financial advice.
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.