OPEN-SOURCE SCRIPT
Volume Weighted Intra Bar LR Correlation

This indicator analyzes market character by providing a detailed
view of correlation. It applies a Linear Regression model to
intra-bar price action, dissecting the total correlation of
each bar into three distinct components.
Key Features:
1. **Three-Component Correlation Decomposition:** The indicator
separates correlation based on the 'Estimate Bar Statistics' option.
- **Standard Mode (`Estimate Bar Statistics` = OFF):** Calculates
correlation based on the selected `Source` (this results
mainly in 'Trend' and 'Residual' correlation).
- **Decomposition Mode (`Estimate Bar Statistics` = ON):** The
indicator uses a statistical model ('Estimator') to
calculate *within-bar* correlation.
(Assumption: In this mode, the `Source` input is
**ignored**, and an estimated mean for each bar is used
instead).
This separates correlation into:
- **Trend Correlation (Green/Red):** Correlation explained by the
regression's slope (Directional Alignment).
- **Residual Correlation (Yellow):** Correlation from price
oscillating around the regression line (Mean-Reversion/Cointegration).
- **Within-Bar Correlation (Blue):** Correlation from the
high-low range of each bar (Microstructure/Noise).
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 decomposition:
- **Absolute Mode:** Displays the *total* correlation as a
stacked area chart, partitioned by the ratio of
the three components.
- **Relative Mode:** Displays the direct *energy ratio*
(proportion) of each component relative to the total (0-1),
ideal for identifying the dominant market character.
4. **Calculation Options:**
- **Normalization:** An optional 'Normalize' setting
calculates an **Exponential Regression Curve** (log-space),
making the analysis suitable for growth assets.
- **Volume Weighting:** An option (`Volume weighted`) applies
volume weighting to all regression and correlation 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 Correlation Lines:** The correlation lines can be
calculated on a higher timeframe, 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 comprehensive 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 applies a Linear Regression model to
intra-bar price action, dissecting the total correlation of
each bar into three distinct components.
Key Features:
1. **Three-Component Correlation Decomposition:** The indicator
separates correlation based on the 'Estimate Bar Statistics' option.
- **Standard Mode (`Estimate Bar Statistics` = OFF):** Calculates
correlation based on the selected `Source` (this results
mainly in 'Trend' and 'Residual' correlation).
- **Decomposition Mode (`Estimate Bar Statistics` = ON):** The
indicator uses a statistical model ('Estimator') to
calculate *within-bar* correlation.
(Assumption: In this mode, the `Source` input is
**ignored**, and an estimated mean for each bar is used
instead).
This separates correlation into:
- **Trend Correlation (Green/Red):** Correlation explained by the
regression's slope (Directional Alignment).
- **Residual Correlation (Yellow):** Correlation from price
oscillating around the regression line (Mean-Reversion/Cointegration).
- **Within-Bar Correlation (Blue):** Correlation from the
high-low range of each bar (Microstructure/Noise).
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 decomposition:
- **Absolute Mode:** Displays the *total* correlation as a
stacked area chart, partitioned by the ratio of
the three components.
- **Relative Mode:** Displays the direct *energy ratio*
(proportion) of each component relative to the total (0-1),
ideal for identifying the dominant market character.
4. **Calculation Options:**
- **Normalization:** An optional 'Normalize' setting
calculates an **Exponential Regression Curve** (log-space),
making the analysis suitable for growth assets.
- **Volume Weighting:** An option (`Volume weighted`) applies
volume weighting to all regression and correlation 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 Correlation Lines:** The correlation lines can be
calculated on a higher timeframe, 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 comprehensive 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 อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน