OPEN-SOURCE SCRIPT
Volume Weighted Intra Bar Correlation

This indicator analyzes market character by providing a detailed
view of correlation. It uses data from a lower, intra-bar timeframe
to separate the total correlation of a single bar into two distinct
components.
Key Features:
1. **Intra-Bar Correlation Decomposition:** For each bar on the chart,
the indicator analyzes the underlying price action on a smaller
timeframe ('Intra-Bar Timeframe') and quantifies two types of correlation:
- **Between-Bar Correlation (Directional):** Calculated from price
movements *between* the intra-bar candles. This component
represents the **macro-movement** correlation within the main bar.
- **Within-Bar Correlation (Non-Directional):** Calculated from
price fluctuations *inside* each intra-bar candle. This
component represents the **microstructure/noise** correlation.
2. **Visual Decomposition Logic:** Total Correlation is the
primary metric displayed. Since Correlation Coefficients are not
linearly additive, this indicator plots the *exact* Total
Correlation and partitions the area underneath based on the
Covariance Ratio. This ensures the displayed total correlation
remains mathematically accurate while showing relative composition.
3. **Dual Display Modes:** The indicator offers two modes to
visualize this information:
- **Absolute Mode:** Plots the *total* correlation as a
stacked column chart, showing the *absolute magnitude* of
correlation and the contribution of each component.
- **Relative Mode:** Plots the components as a 100% stacked
column chart (scaled from 0 to 1), focusing purely on the
*energy ratio* of 'between-bar' (macro) and 'within-bar' (micro)
correlation.
4. **Calculation Options:**
- **Normalization:** An optional 'Normalize' setting
calculates an **Exponential Regression Curve** (log-space),
making the analysis suitable for comparing assets with
different scales (e.g., BTC vs EURUSD).
- **Volume Weighting:** An option (`Volume weighted`) applies
volume weighting to all mean and covariance calculations.
5. **Correlation Cycle Analysis:**
- **Pivot Detection:** Includes a built-in pivot detector
that identifies significant turning points (highs and lows) in
the *total* correlation line. (Note: This is only visible
in 'Absolute Mode').
- **Flexible Pivot Algorithms:** Supports various underlying
mathematical models for pivot detection provided by the
core library.
6. **Note on Confirmation (Lag):** Pivot signals are confirmed
using a lookback method. A pivot is only plotted *after*
the `Pivot Right Bars` input has passed, which introduces
an inherent lag.
7. **Multi-Timeframe (MTF) Capability:**
- **MTF Analysis Lines:** The entire intra-bar analysis can be
run on a higher timeframe (using the `Timeframe` input),
with standard options to handle gaps (`Fill Gaps`) and
prevent repainting (`Wait for...`).
- **Limitation:** The Pivot detection (`Calculate Pivots`) is
**disabled** if a Higher Timeframe (HTF) is selected.
8. **Integrated Alerts:** Includes alerts for:
- Correlation magnitude (High Positive / High Inverse).
- Correlation character changes/emerging/fading.
- Total Correlation pivot (High/Low) detection.
**Caution: Real-Time Data Behavior (Intra-Bar Repainting)**
This indicator uses high-resolution intra-bar data. As a result, the
values on the **current, unclosed bar** (the real-time bar) will
update dynamically as new intra-bar data arrives. This behavior is
normal and necessary for this type of analysis. Signals should only
be considered final **after the main chart bar has closed.**
---
**DISCLAIMER**
1. **For Informational/Educational Use Only:** This indicator is
provided for informational and educational purposes only. It does
not constitute financial, investment, or trading advice, nor is
it a recommendation to buy or sell any asset.
2. **Use at Your Own Risk:** All trading decisions you make based on
the information or signals generated by this indicator are made
solely at your own risk.
3. **No Guarantee of Performance:** Past performance is not an
indicator of future results. The author makes no guarantee
regarding the accuracy of the signals or future profitability.
4. **No Liability:** The author shall not be held liable for any
financial losses or damages incurred directly or indirectly from
the use of this indicator.
5. **Signals Are Not Recommendations:** The alerts and visual signals
(e.g., crossovers) generated by this tool are not direct
recommendations to buy or sell. They are technical observations
for your own analysis and consideration.
view of correlation. It uses data from a lower, intra-bar timeframe
to separate the total correlation of a single bar into two distinct
components.
Key Features:
1. **Intra-Bar Correlation Decomposition:** For each bar on the chart,
the indicator analyzes the underlying price action on a smaller
timeframe ('Intra-Bar Timeframe') and quantifies two types of correlation:
- **Between-Bar Correlation (Directional):** Calculated from price
movements *between* the intra-bar candles. This component
represents the **macro-movement** correlation within the main bar.
- **Within-Bar Correlation (Non-Directional):** Calculated from
price fluctuations *inside* each intra-bar candle. This
component represents the **microstructure/noise** correlation.
2. **Visual Decomposition Logic:** Total Correlation is the
primary metric displayed. Since Correlation Coefficients are not
linearly additive, this indicator plots the *exact* Total
Correlation and partitions the area underneath based on the
Covariance Ratio. This ensures the displayed total correlation
remains mathematically accurate while showing relative composition.
3. **Dual Display Modes:** The indicator offers two modes to
visualize this information:
- **Absolute Mode:** Plots the *total* correlation as a
stacked column chart, showing the *absolute magnitude* of
correlation and the contribution of each component.
- **Relative Mode:** Plots the components as a 100% stacked
column chart (scaled from 0 to 1), focusing purely on the
*energy ratio* of 'between-bar' (macro) and 'within-bar' (micro)
correlation.
4. **Calculation Options:**
- **Normalization:** An optional 'Normalize' setting
calculates an **Exponential Regression Curve** (log-space),
making the analysis suitable for comparing assets with
different scales (e.g., BTC vs EURUSD).
- **Volume Weighting:** An option (`Volume weighted`) applies
volume weighting to all mean and covariance calculations.
5. **Correlation Cycle Analysis:**
- **Pivot Detection:** Includes a built-in pivot detector
that identifies significant turning points (highs and lows) in
the *total* correlation line. (Note: This is only visible
in 'Absolute Mode').
- **Flexible Pivot Algorithms:** Supports various underlying
mathematical models for pivot detection provided by the
core library.
6. **Note on Confirmation (Lag):** Pivot signals are confirmed
using a lookback method. A pivot is only plotted *after*
the `Pivot Right Bars` input has passed, which introduces
an inherent lag.
7. **Multi-Timeframe (MTF) Capability:**
- **MTF Analysis Lines:** The entire intra-bar analysis can be
run on a higher timeframe (using the `Timeframe` input),
with standard options to handle gaps (`Fill Gaps`) and
prevent repainting (`Wait for...`).
- **Limitation:** The Pivot detection (`Calculate Pivots`) is
**disabled** if a Higher Timeframe (HTF) is selected.
8. **Integrated Alerts:** Includes alerts for:
- Correlation magnitude (High Positive / High Inverse).
- Correlation character changes/emerging/fading.
- Total Correlation pivot (High/Low) detection.
**Caution: Real-Time Data Behavior (Intra-Bar Repainting)**
This indicator uses high-resolution intra-bar data. As a result, the
values on the **current, unclosed bar** (the real-time bar) will
update dynamically as new intra-bar data arrives. This behavior is
normal and necessary for this type of analysis. Signals should only
be considered final **after the main chart bar has closed.**
---
**DISCLAIMER**
1. **For Informational/Educational Use Only:** This indicator is
provided for informational and educational purposes only. It does
not constitute financial, investment, or trading advice, nor is
it a recommendation to buy or sell any asset.
2. **Use at Your Own Risk:** All trading decisions you make based on
the information or signals generated by this indicator are made
solely at your own risk.
3. **No Guarantee of Performance:** Past performance is not an
indicator of future results. The author makes no guarantee
regarding the accuracy of the signals or future profitability.
4. **No Liability:** The author shall not be held liable for any
financial losses or damages incurred directly or indirectly from
the use of this indicator.
5. **Signals Are Not Recommendations:** The alerts and visual signals
(e.g., crossovers) generated by this tool are not direct
recommendations to buy or sell. They are technical observations
for your own analysis and consideration.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.