INVITE-ONLY SCRIPT

Daily Close Probability

300
Daily Close Probability is a quantitative indicator that estimates the probability of the current and next daily candle closing green (bullish) or red (bearish). It analyzes historical patterns of daily candle sequences, builds an adaptive probability set, and combines multiple filters to produce a refined directional forecast.

The indicator operates on daily data regardless of the chart timeframe, so it can be applied to intraday charts without losing its daily reference. This allows traders working on lower timeframes to keep the broader daily directional bias visible at all times.

How It Works
The core engine examines how daily candles have historically followed one another. It tracks not only simple one-step transitions (what tends to happen after a green day or a red day) but also two-step sequences (what tends to happen after two consecutive green days, a green followed by a red, and so on). These observed frequencies form an adaptive probability matrix that updates as new data becomes available.

Rather than using the entire available history, the engine operates on a configurable sliding window. A shorter window makes the model more responsive to recent market behavior, while a longer window provides more statistical stability. This design allows the model to naturally adapt to changing market conditions without manual intervention.

The indicator provides two probability outputs:

Today's Probability — The estimated likelihood of the current daily candle closing green or red, updated in real time as the day progresses.
Tomorrow's Probability — The estimated likelihood of the next daily candle closing green or red, calculated using a two-step transition method that accounts for the uncertainty of today's outcome.
Filters
The raw probability estimate can be enhanced through several optional filters, each adding a layer of contextual information:

Trend Filter (EMA)
When enabled, the model conditions its analysis on whether price is trading above or below a daily EMA. Transitions that occurred in an uptrend are counted separately from those in a downtrend, producing trend-aware probabilities. This significantly improves accuracy in trending markets.

Second Order Analysis
Instead of considering only the previous candle, this filter examines the pattern of the last two candles. This captures more nuanced sequences — for example, the market may behave differently after two consecutive green days compared to a single green day preceded by a red one.

Intraday Session Bias
This filter incorporates the direction of an early intraday candle as a leading signal for the daily close. Markets often establish a directional tone during the initial phase of the session, and this early momentum tends to correlate with the final outcome of the day. When enabled, the model conditions its estimate on whether this early session candle closed bullish or bearish, adding an intraday layer to the daily probability calculation.

Current Candle Bias
As the trading day progresses, the size and direction of the current candle become increasingly informative. This filter dynamically adjusts today's probability based on the current candle's size relative to ATR and how much time has elapsed in the session. The effect strengthens as the day advances and weakens near the open when the candle body is still small.

Minimum Confidence Threshold
A configurable threshold that filters out weak signals. When the estimated probability does not exceed this level, the signal is considered inconclusive. This reduces noise and focuses attention on higher-conviction setups. In the backtest, trades that fall below the threshold are skipped and reported separately.

Visual Output
Background Color
The chart background is shaded green or red according to the predicted daily close direction. Stronger signals produce more vivid coloring, while signals below the confidence threshold appear faded, providing an immediate visual distinction between high-conviction and uncertain forecasts.

Information Table
A detailed on-chart table displays:

Current candle state and trend context
Today's and tomorrow's green/red probabilities with directional markers
The complete first-order and second-order transition matrices with counts
First hour bias statistics
Sample quality assessment
Backtest results with win rates and signal counts
Built-in Backtest
The indicator includes a rigorous walk-forward backtest that simulates how the model would have performed historically, without any look-ahead bias.

How the backtest works:
For each historical day in the test period, the model is retrained using only data available up to that point — exactly as it would operate in real time. The prediction is then compared against the actual outcome. This process repeats across the entire backtest period, producing a realistic win rate.

Two backtest modes are reported:

Today — For each day, the model predicts whether that day will close green or red using data available at the open. The prediction is compared against the actual close.

Tomorrow — For each day, the model predicts the next day's close direction using only information available today. Since today's candle has not yet closed at the time of prediction, the model uses a two-step probability calculation that accounts for all possible outcomes of the current day. This provides a genuinely forward-looking accuracy measure.

The backtest period and the probability matrix window are configured independently. This allows testing a fast-adapting model (short window) over a long historical period (many trades), producing statistically meaningful results.

Shorter windows adapt faster to regime changes but require more historical data in the backtest to validate performance. When activating multiple filters, a larger window is recommended to ensure each sub-category has sufficient sample size.

Important Notes
- This indicator estimates probabilities, not certainties. A 60% probability of a green close still implies a 40% chance of a red close.
- Past statistical patterns may not persist in the future. Market regimes change, and the model's accuracy can degrade during transitions.
- The backtest reflects historical performance under ideal conditions and does not account for execution, slippage, or transaction costs.
- Best used as a confluence tool alongside price action, support/resistance, and risk management — not as a standalone trading signal.

Aviso legal

As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.