OPEN-SOURCE SCRIPT
Brownian Motion Probabilistic Forecasting (Time Adaptive)

Probabilistic Price Forecast Indicator
[hr][/hr]
Overview
The Probabilistic Price Forecast is an advanced technical analysis tool designed for the TradingView platform. Instead of predicting a single future price, this indicator uses a Monte Carlo simulation to model thousands of potential future price paths, generating a cone of possibilities and calculating the probability of specific outcomes.
This allows traders to move beyond simple price targets and ask more sophisticated questions, such as: "What is the probability that this stock will increase by 5% over the next 24 hours?"
Core Concept: Geometric Brownian Motion
The indicator's forecasting model is built on the principles of Geometric Brownian Motion (GBM), a widely accepted mathematical model for describing the random movements of financial asset prices. The core idea is that the next price step is a function of the asset's historical trend (drift), its volatility, and a random "shock."
The formula used to project each price step in the simulation is:
Pine Script®
Where:
How It Works
The indicator performs a comprehensive analysis on the most recent bar of the chart:
Key Features & Configuration
The indicator is highly configurable, allowing you to tailor its analysis to your specific needs.
Time-Adaptive Periods
The lookback and forecast periods are defined in hours, not bars. The script automatically converts these hour-based inputs into the correct number of bars based on the chart's current timeframe, ensuring the analysis remains consistent across different chart resolutions.
Forecast Quartiles
You can visualize the forecast as a "cone of probability" on the chart. The indicator draws lines and a shaded area representing the price levels for different quartiles (percentiles) of the simulation results. By default, this shows the range between the 25th and 95th percentiles.
Independent Bullish and Bearish Signals
The indicator allows you to set independent criteria for bullish and bearish signals, providing greater flexibility. You can configure:
For example, you can set it to alert you for a 90% chance of a 2% drop, while simultaneously looking for a 60% chance of a 10% rally.
How to Interpret the Indicator
This tool provides a statistical edge for understanding future possibilities but should be used in conjunction with other analysis techniques.
[hr][/hr]
Overview
The Probabilistic Price Forecast is an advanced technical analysis tool designed for the TradingView platform. Instead of predicting a single future price, this indicator uses a Monte Carlo simulation to model thousands of potential future price paths, generating a cone of possibilities and calculating the probability of specific outcomes.
This allows traders to move beyond simple price targets and ask more sophisticated questions, such as: "What is the probability that this stock will increase by 5% over the next 24 hours?"
Core Concept: Geometric Brownian Motion
The indicator's forecasting model is built on the principles of Geometric Brownian Motion (GBM), a widely accepted mathematical model for describing the random movements of financial asset prices. The core idea is that the next price step is a function of the asset's historical trend (drift), its volatility, and a random "shock."
The formula used to project each price step in the simulation is:
next_price = current_price * exp( (μ - (σ²/2))Δt + σZ√(Δt) )
Where:
- μ (mu) represents the drift, which is the average historical return.
- σ (sigma) represents the volatility, measured by the standard deviation of historical returns.
- Z is a random variable from a standard normal distribution, representing the random "shock" or new information affecting the price.
- Δt (delta t) is the time step for each projection.
How It Works
The indicator performs a comprehensive analysis on the most recent bar of the chart:
- **Historical Analysis**: It first analyzes a user-defined historical period (e.g., the last 240 hours of price data) to calculate the asset's historical drift (μ) and volatility (σ) from its logarithmic returns.
- **Monte Carlo Simulation**: It then runs thousands of simulations (e.g., 2000) of future price paths over a specified forecast period (e.g., the next 24 hours). Each path is unique due to the random shock (Z) applied at every step.
- **Probability Distribution**: After all simulations are complete, it collects the final price of each path and sorts them to build a probability distribution of potential outcomes.
- **Visualization and Signaling**: Finally, it visualizes this distribution on the chart and generates signals based on the user's criteria.
Key Features & Configuration
The indicator is highly configurable, allowing you to tailor its analysis to your specific needs.
Time-Adaptive Periods
The lookback and forecast periods are defined in hours, not bars. The script automatically converts these hour-based inputs into the correct number of bars based on the chart's current timeframe, ensuring the analysis remains consistent across different chart resolutions.
Forecast Quartiles
You can visualize the forecast as a "cone of probability" on the chart. The indicator draws lines and a shaded area representing the price levels for different quartiles (percentiles) of the simulation results. By default, this shows the range between the 25th and 95th percentiles.
Independent Bullish and Bearish Signals
The indicator allows you to set independent criteria for bullish and bearish signals, providing greater flexibility. You can configure:
- A bullish signal for an X% confidence of a Y% price increase.
- A bearish signal for a W% confidence of a Z% price decrease.
For example, you can set it to alert you for a 90% chance of a 2% drop, while simultaneously looking for a 60% chance of a 10% rally.
How to Interpret the Indicator
- The Forecast Cone: The blue shaded area on the chart represents the probable range of future prices. The width of the cone indicates the expected volatility; a wider cone means higher uncertainty. The price labels on the right side of the cone show the calculated percentile levels at the end of the forecast period.
- Green Signal Label: A green "UP signal" label appears when the probability of the price increasing by your target percentage exceeds your defined confidence level.
- Red Signal Label: A red "DOWN signal" label appears when the probability of the price decreasing by your target percentage exceeds your confidence level.
This tool provides a statistical edge for understanding future possibilities but should be used in conjunction with other analysis techniques.
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit de TradingView, le créateur de ce script l'a rendu open-source, afin que les traders puissent examiner et vérifier sa fonctionnalité. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais n'oubliez pas que la republication du code est soumise à nos Règles.
Clause de non-responsabilité
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.