OPEN-SOURCE SCRIPT
Volume Weighted Kurtosis

This indicator analyzes market sentiment by decomposing total
Excess Kurtosis ("Fat Tails") into distinct, interpretable components:
"Between-Bar" (Trend Path) and "Within-Bar" (Microstructure).
Key Features:
1. **Moment-Based Kurtosis Decomposition:** The indicator
separates kurtosis based on the 'Estimate Bar Statistics' option.
It leverages the additive property of the Fourth Central Moment
(Cumulants) to ensure mathematical rigor:
- **Standard Mode (`Estimate Bar Statistics` = OFF):** Calculates
simple kurtosis of the selected `Source`.
- **Decomposition Mode (`Estimate Bar Statistics` = ON):** The
indicator uses a statistical model ('Estimator') to
calculate *within-bar* kurtosis.
This separates the tail risk into:
- **Between-Bar Kurtosis (Gold):** Peakedness of the price
path itself. High values indicate the trend moves in jumps
or gaps rather than a smooth progression.
- **Within-Bar Kurtosis (Blue):** Fat tails within the
microstructure. High values imply significant outliers
inside the bars (e.g., extreme wicks).
- **Interaction Variance (Dark Grey):** The comovement of variance
and mean deviations (volatility clustering relative to trend).
- **Interaction Skewness (Darker Grey):** The comovement of skewness
and mean deviations (asymmetry relative to trend).
2. **Visual Decomposition Logic:** Total Excess Kurtosis is the
primary metric displayed. Since Kurtosis coefficients are not
linearly additive, this indicator calculates the *exact* Total
Kurtosis and partitions the area/ratios based on the additive
Fourth Moment Decomposition (`M4Tot = M4Btw + M4Wtn + M4Int`). This
ensures the displayed total kurtosis remains mathematically accurate.
3. **Dual Display Modes:** The indicator offers two modes to
visualize this decomposition:
- **Absolute Mode:** Displays the *Total Kurtosis* as the main
line, with the background filled by the stacked components.
Shows the *magnitude* of the tail risk.
- **Relative Mode:** Displays the **Contribution Ratios**
of each component (-1.0 to 1.0). This isolates the
*structure/quality* of the risk (e.g., "Is the risk
driven by the trend jumps or by the candle instability?").
4. **Calculation Options:**
- **Normalization:** An optional 'Normalize' setting
transforms inputs into logarithmic space, analyzing the
kurtosis of *returns* rather than absolute prices.
(Essential for correct statistical properties).
- **Volume Weighting:** An option (`Volume weighted`) applies
volume weighting to all moment calculations, emphasizing
high-participation moves.
5. **Kurtosis Cycle Analysis:**
- **Pivot Detection:** Includes a built-in pivot detector
that identifies significant turning points (peaks/valleys) in
the *Total Kurtosis* 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 Kurtosis Lines:** The kurtosis 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:
- Kurtosis magnitude (High Positive / High Negative).
- Character changes (Inter-Bar vs. Intra-Bar dominance).
- Total Kurtosis pivot (High/Low) detection.
---
**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.
Excess Kurtosis ("Fat Tails") into distinct, interpretable components:
"Between-Bar" (Trend Path) and "Within-Bar" (Microstructure).
Key Features:
1. **Moment-Based Kurtosis Decomposition:** The indicator
separates kurtosis based on the 'Estimate Bar Statistics' option.
It leverages the additive property of the Fourth Central Moment
(Cumulants) to ensure mathematical rigor:
- **Standard Mode (`Estimate Bar Statistics` = OFF):** Calculates
simple kurtosis of the selected `Source`.
- **Decomposition Mode (`Estimate Bar Statistics` = ON):** The
indicator uses a statistical model ('Estimator') to
calculate *within-bar* kurtosis.
This separates the tail risk into:
- **Between-Bar Kurtosis (Gold):** Peakedness of the price
path itself. High values indicate the trend moves in jumps
or gaps rather than a smooth progression.
- **Within-Bar Kurtosis (Blue):** Fat tails within the
microstructure. High values imply significant outliers
inside the bars (e.g., extreme wicks).
- **Interaction Variance (Dark Grey):** The comovement of variance
and mean deviations (volatility clustering relative to trend).
- **Interaction Skewness (Darker Grey):** The comovement of skewness
and mean deviations (asymmetry relative to trend).
2. **Visual Decomposition Logic:** Total Excess Kurtosis is the
primary metric displayed. Since Kurtosis coefficients are not
linearly additive, this indicator calculates the *exact* Total
Kurtosis and partitions the area/ratios based on the additive
Fourth Moment Decomposition (`M4Tot = M4Btw + M4Wtn + M4Int`). This
ensures the displayed total kurtosis remains mathematically accurate.
3. **Dual Display Modes:** The indicator offers two modes to
visualize this decomposition:
- **Absolute Mode:** Displays the *Total Kurtosis* as the main
line, with the background filled by the stacked components.
Shows the *magnitude* of the tail risk.
- **Relative Mode:** Displays the **Contribution Ratios**
of each component (-1.0 to 1.0). This isolates the
*structure/quality* of the risk (e.g., "Is the risk
driven by the trend jumps or by the candle instability?").
4. **Calculation Options:**
- **Normalization:** An optional 'Normalize' setting
transforms inputs into logarithmic space, analyzing the
kurtosis of *returns* rather than absolute prices.
(Essential for correct statistical properties).
- **Volume Weighting:** An option (`Volume weighted`) applies
volume weighting to all moment calculations, emphasizing
high-participation moves.
5. **Kurtosis Cycle Analysis:**
- **Pivot Detection:** Includes a built-in pivot detector
that identifies significant turning points (peaks/valleys) in
the *Total Kurtosis* 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 Kurtosis Lines:** The kurtosis 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:
- Kurtosis magnitude (High Positive / High Negative).
- Character changes (Inter-Bar vs. Intra-Bar dominance).
- Total Kurtosis pivot (High/Low) detection.
---
**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 อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน