OPEN-SOURCE SCRIPT
Analyst Targets Probability

This indicator calculates the probability of the current stock price reaching or exceeding the analyst-provided high, average, and low price targets within a one-year time horizon. It utilizes a geometric Brownian motion (GBM) model, a standard approach in financial modeling that assumes log-normal price distribution with constant volatility.
### Key Features:
- **Analyst Targets**: Automatically pulls the high, average, and low one-year price targets from TradingView's syminfo data.
- **Risk-Free Rate**: Fetched from the 1-year US Treasury yield (symbol: TVC:US01Y). Defaults to 4% if unavailable.
- **Dividend Yield**: Uses trailing twelve-month (TTM) dividends per share (DPS) from financial data, divided by current price. Defaults to 0% if unavailable.
- **Volatility**: Computed as annualized historical volatility based on 252 trading days of daily log returns. Falls back to a 20-day period if insufficient data, or defaults to 30% if still unavailable.
- **Probability Calculation**: Employs the barrier hitting probability formula under GBM:
- Drift (μ) = risk-free rate - dividend yield - (volatility² / 2)
- The formula for probability P of hitting target H from current price S₀ over time T is:
P = Φ(d₊) + (H / S₀)^p ⋅ Φ(d₋) for H > S₀ (or adjusted for H < S₀)
Where l = ln(max(H, S₀)/min(H, S₀)), ν = drift, p = -2ν / σ², d₊ = (-l + νT) / (σ√T), d₋ = (-l - νT) / (σ√T), and Φ is the standard normal CDF (approximated using a polynomial method for accuracy).
- **Output Display**: A table in the top-right corner shows each target type, its value, and the estimated probability (as a percentage). "N/A" appears if data is unavailable or calculations cannot proceed (e.g., zero volatility).
### Assumptions and Limitations:
- Assumes constant volatility and drift, no transaction costs, and continuous trading (real markets may deviate due to jumps, news events, or changing conditions).
- Probabilities are model-based estimates and not guarantees; they represent the likelihood under risk-neutral measure.
- Best suited for stocks with available analyst targets and historical data; may default to assumptions for less-liquid symbols.
- No user inputs required—fully automated using TradingView's data sources.
This script is provided under the Mozilla Public License 2.0. For educational and informational purposes only; not financial advice. Test on your charts and consider backtesting for validation.
### Key Features:
- **Analyst Targets**: Automatically pulls the high, average, and low one-year price targets from TradingView's syminfo data.
- **Risk-Free Rate**: Fetched from the 1-year US Treasury yield (symbol: TVC:US01Y). Defaults to 4% if unavailable.
- **Dividend Yield**: Uses trailing twelve-month (TTM) dividends per share (DPS) from financial data, divided by current price. Defaults to 0% if unavailable.
- **Volatility**: Computed as annualized historical volatility based on 252 trading days of daily log returns. Falls back to a 20-day period if insufficient data, or defaults to 30% if still unavailable.
- **Probability Calculation**: Employs the barrier hitting probability formula under GBM:
- Drift (μ) = risk-free rate - dividend yield - (volatility² / 2)
- The formula for probability P of hitting target H from current price S₀ over time T is:
P = Φ(d₊) + (H / S₀)^p ⋅ Φ(d₋) for H > S₀ (or adjusted for H < S₀)
Where l = ln(max(H, S₀)/min(H, S₀)), ν = drift, p = -2ν / σ², d₊ = (-l + νT) / (σ√T), d₋ = (-l - νT) / (σ√T), and Φ is the standard normal CDF (approximated using a polynomial method for accuracy).
- **Output Display**: A table in the top-right corner shows each target type, its value, and the estimated probability (as a percentage). "N/A" appears if data is unavailable or calculations cannot proceed (e.g., zero volatility).
### Assumptions and Limitations:
- Assumes constant volatility and drift, no transaction costs, and continuous trading (real markets may deviate due to jumps, news events, or changing conditions).
- Probabilities are model-based estimates and not guarantees; they represent the likelihood under risk-neutral measure.
- Best suited for stocks with available analyst targets and historical data; may default to assumptions for less-liquid symbols.
- No user inputs required—fully automated using TradingView's data sources.
This script is provided under the Mozilla Public License 2.0. For educational and informational purposes only; not financial advice. Test on your charts and consider backtesting for validation.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.