OPEN-SOURCE SCRIPT
Candle Microstructure Classifier

Candle Microstructure Classifier
Public Description
The Candle Microstructure Classifier is a visual study designed to highlight meaningful single-candle behaviors based purely on price geometry. It classifies candles according to body size and wick structure, helping traders visually identify moments of aggression, commitment, failed pushes, and rejection directly on the price chart.
This script is a study only. It does not generate trade signals, entries, exits, or forecasts. Its purpose is to provide structural context that can be combined with other tools such as trend, volume, or volatility analysis.
Quantitative Description
Each candle is decomposed into its geometric components relative to its total range (high − low). All classifications are based on normalized fractions to remain scale‑independent across instruments and timeframes.
Definitions:
1. Candle Range (R):
R = High − Low
2. Body Size (B):
B = |Close − Open|
Body Fraction = B / R
3. Upper Wick (UW):
UW = High − max(Open, Close)
Upper Wick Fraction = UW / R
4. Lower Wick (LW):
LW = min(Open, Close) − Low
Lower Wick Fraction = LW / R
Candle Classifications:
• Commitment Candle:
Body Fraction ≥ Large Body Threshold
Upper Wick Fraction ≤ Tiny Wick Threshold
Lower Wick Fraction ≤ Tiny Wick Threshold
Interpretation: Strong directional acceptance with minimal intrabar rejection.
• Marubozu (Aggression):
Body Fraction ≥ Large Body Threshold
One wick effectively absent (near zero)
Interpretation: Pure directional aggression with no meaningful counter‑pressure.
• Trend Attempt Failure:
Body Fraction ≥ Large Body Threshold
One wick large, opposite wick small
Interpretation: Strong push followed by immediate rejection on one side.
• Rejection Candle:
Body Fraction ≤ Small Body Threshold
Upper Wick Fraction ≥ Large Wick Threshold
Lower Wick Fraction ≥ Large Wick Threshold
Interpretation: Two‑sided rejection indicating price discovery or balance.
• Pin Rejection (optional):
Body Fraction ≤ Small Body Threshold
Only one wick large
Interpretation: One‑sided rejection often occurring near support or resistance.
Notes and Context
This classifier intentionally avoids pattern names tied to prediction. Each classification describes observed auction behavior inside a single bar, not an expectation of future movement.
Sources and Further Reading
Candle structure and wick interpretation:
• Investopedia – Candlestick Patterns and Anatomy
investopedia.com/trading/candlestick-charting-what-is-it/
Volume and volatility context examples:
• Wyckoff Method – Effort vs Result (Volume + Price Structure)
school.stockcharts.com/doku.php?id=market_analysis:wyckoff_method
• CME Group – Using Volume and Volatility Together
cmegroup.com/education/articles-and-reports/volume-and-volatility.html
Example Applications:
1. A commitment candle occurring simultaneously with a volume spike may indicate institutional participation and acceptance at that price level.
2. A rejection candle forming during elevated volatility (ATR expansion) may signal failed price discovery and potential mean reversion zones.
Public Description
The Candle Microstructure Classifier is a visual study designed to highlight meaningful single-candle behaviors based purely on price geometry. It classifies candles according to body size and wick structure, helping traders visually identify moments of aggression, commitment, failed pushes, and rejection directly on the price chart.
This script is a study only. It does not generate trade signals, entries, exits, or forecasts. Its purpose is to provide structural context that can be combined with other tools such as trend, volume, or volatility analysis.
Quantitative Description
Each candle is decomposed into its geometric components relative to its total range (high − low). All classifications are based on normalized fractions to remain scale‑independent across instruments and timeframes.
Definitions:
1. Candle Range (R):
R = High − Low
2. Body Size (B):
B = |Close − Open|
Body Fraction = B / R
3. Upper Wick (UW):
UW = High − max(Open, Close)
Upper Wick Fraction = UW / R
4. Lower Wick (LW):
LW = min(Open, Close) − Low
Lower Wick Fraction = LW / R
Candle Classifications:
• Commitment Candle:
Body Fraction ≥ Large Body Threshold
Upper Wick Fraction ≤ Tiny Wick Threshold
Lower Wick Fraction ≤ Tiny Wick Threshold
Interpretation: Strong directional acceptance with minimal intrabar rejection.
• Marubozu (Aggression):
Body Fraction ≥ Large Body Threshold
One wick effectively absent (near zero)
Interpretation: Pure directional aggression with no meaningful counter‑pressure.
• Trend Attempt Failure:
Body Fraction ≥ Large Body Threshold
One wick large, opposite wick small
Interpretation: Strong push followed by immediate rejection on one side.
• Rejection Candle:
Body Fraction ≤ Small Body Threshold
Upper Wick Fraction ≥ Large Wick Threshold
Lower Wick Fraction ≥ Large Wick Threshold
Interpretation: Two‑sided rejection indicating price discovery or balance.
• Pin Rejection (optional):
Body Fraction ≤ Small Body Threshold
Only one wick large
Interpretation: One‑sided rejection often occurring near support or resistance.
Notes and Context
This classifier intentionally avoids pattern names tied to prediction. Each classification describes observed auction behavior inside a single bar, not an expectation of future movement.
Sources and Further Reading
Candle structure and wick interpretation:
• Investopedia – Candlestick Patterns and Anatomy
investopedia.com/trading/candlestick-charting-what-is-it/
Volume and volatility context examples:
• Wyckoff Method – Effort vs Result (Volume + Price Structure)
school.stockcharts.com/doku.php?id=market_analysis:wyckoff_method
• CME Group – Using Volume and Volatility Together
cmegroup.com/education/articles-and-reports/volume-and-volatility.html
Example Applications:
1. A commitment candle occurring simultaneously with a volume spike may indicate institutional participation and acceptance at that price level.
2. A rejection candle forming during elevated volatility (ATR expansion) may signal failed price discovery and potential mean reversion zones.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.