OPEN-SOURCE SCRIPT
Two Candle Theory (Filtered) - Labels & Colors

Overview
This Pine Script classifies each candle into one of nine sentiment categories based on how the candle closes within its own range and in relation to the previous candle’s high and low. It optionally filters the strongest bullish and bearish signals based on volume spikes.
The script is designed to help traders visually interpret market sentiment through configurable labels and candle colors.
⸻
Classification Logic
Each candle is assessed using two metrics:
1. Close Position – where the candle closes within its own high-low range (High, Mid, Low).
2. Close Comparison – how the current close compares to the previous candle’s high and low (Bull, Bear, or Range).
Based on this, a short label is assigned:
• Bullish Bias: Strongest (SBu), Moderate (MBu), Weak (WBu), Slight (SlB)
• Neutral: Neutral (N)
• Bearish Bias: Slight (SlS), Weak (WBa), Moderate (MBa), Strongest (SBa)
⸻
Volume Filter
A volume spike filter can be applied to the strongest signals:
• SBu and SBa are only shown if volume is significantly higher than the average (SMA × threshold).
• The filter is optional and user-configurable.
⸻
Display Options
Users can control:
• Whether to show labels, bar colors, or both.
• Which of the nine label types are visible.
• Custom colors for each label and corresponding bar.
⸻
Visual Output
• Labels appear above or below candles depending on bullish or bearish classification.
• Bar colors reflect sentiment for quicker visual scanning.
⸻
Use Case
Ideal for identifying momentum shifts, validating trade entries, and highlighting candles that break out of previous ranges with conviction and/or volume.
⸻
Summary
This script simplifies price action by translating each candle into an interpretable sentiment label and color. With optional volume filtering and full display customization, it offers a practical tool for discretionary and systematic traders alike.
This Pine Script classifies each candle into one of nine sentiment categories based on how the candle closes within its own range and in relation to the previous candle’s high and low. It optionally filters the strongest bullish and bearish signals based on volume spikes.
The script is designed to help traders visually interpret market sentiment through configurable labels and candle colors.
⸻
Classification Logic
Each candle is assessed using two metrics:
1. Close Position – where the candle closes within its own high-low range (High, Mid, Low).
2. Close Comparison – how the current close compares to the previous candle’s high and low (Bull, Bear, or Range).
Based on this, a short label is assigned:
• Bullish Bias: Strongest (SBu), Moderate (MBu), Weak (WBu), Slight (SlB)
• Neutral: Neutral (N)
• Bearish Bias: Slight (SlS), Weak (WBa), Moderate (MBa), Strongest (SBa)
⸻
Volume Filter
A volume spike filter can be applied to the strongest signals:
• SBu and SBa are only shown if volume is significantly higher than the average (SMA × threshold).
• The filter is optional and user-configurable.
⸻
Display Options
Users can control:
• Whether to show labels, bar colors, or both.
• Which of the nine label types are visible.
• Custom colors for each label and corresponding bar.
⸻
Visual Output
• Labels appear above or below candles depending on bullish or bearish classification.
• Bar colors reflect sentiment for quicker visual scanning.
⸻
Use Case
Ideal for identifying momentum shifts, validating trade entries, and highlighting candles that break out of previous ranges with conviction and/or volume.
⸻
Summary
This script simplifies price action by translating each candle into an interpretable sentiment label and color. With optional volume filtering and full display customization, it offers a practical tool for discretionary and systematic traders alike.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.