OPEN-SOURCE SCRIPT
Green/Red Candle Conditional Probability V2

Conditional Next-Candle Probability Analyzer
This indicator calculates the historical probability of the next candle being green based on current market conditions. Unlike simple candle counters, it tracks conditional probabilities.
How It Works:
Monitors 20+ market conditions across trend, momentum, volatility, volume, and candle patterns
For each condition, tracks: "When this was true, what % of next candles were green?"
Combines active conditions into a weighted probability prediction
Weights by sample size (more historical data = more influence)
Conditions Tracked:
Trend alignment (EMA 7 / SMA 20 / SMA 200)
RSI levels and momentum
MACD position, histogram, and crosses
Consecutive candle streaks (3-4 in a row)
Bollinger Band touches and squeeze/expansion
Volume spikes and anomalies
Large candles and rejection wicks
Table Display:
P(Grn): Probability next candle is green when condition is active
Edge: Deviation from 50% (how predictive the condition is)
N: Sample size (historical occurrences)
► marks currently active conditions
Signals:
Plots arrows when multiple conditions align with sufficient confidence (configurable threshold).
Use Cases:
Identify which setups have actual predictive value on your asset/timeframe
Find confluence zones where multiple high-edge conditions align
Backtest mean-reversion vs momentum characteristics
Note: Edges are typically small (2-5%). Best used for confluence confirmation, not standalone signals.
This indicator calculates the historical probability of the next candle being green based on current market conditions. Unlike simple candle counters, it tracks conditional probabilities.
How It Works:
Monitors 20+ market conditions across trend, momentum, volatility, volume, and candle patterns
For each condition, tracks: "When this was true, what % of next candles were green?"
Combines active conditions into a weighted probability prediction
Weights by sample size (more historical data = more influence)
Conditions Tracked:
Trend alignment (EMA 7 / SMA 20 / SMA 200)
RSI levels and momentum
MACD position, histogram, and crosses
Consecutive candle streaks (3-4 in a row)
Bollinger Band touches and squeeze/expansion
Volume spikes and anomalies
Large candles and rejection wicks
Table Display:
P(Grn): Probability next candle is green when condition is active
Edge: Deviation from 50% (how predictive the condition is)
N: Sample size (historical occurrences)
► marks currently active conditions
Signals:
Plots arrows when multiple conditions align with sufficient confidence (configurable threshold).
Use Cases:
Identify which setups have actual predictive value on your asset/timeframe
Find confluence zones where multiple high-edge conditions align
Backtest mean-reversion vs momentum characteristics
Note: Edges are typically small (2-5%). Best used for confluence confirmation, not standalone signals.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.