OPEN-SOURCE SCRIPT
已更新 Guassian Distribution Forecast [prediction intervals]

The Indicator
The Indicator combines volatility and frequency distributions to forecast an area of possible price expansion with an approximate confidence interval / level and level of significance (significance level).
The Script Formula

Additional comments
To alter the models forecasting precision to reflect a given confidence interval, e.g the 90% confidence level (C.L.), use the 1.64 multiplier (toggle value in "Standard normal distribution sd" setting), to use a specific C.L., e.g. the 85th percentile either search for this on google, or calculate it yourself using a Standard Normal Distribution Probability table. Additionaly volatility may be changed by toggling the lookback period setting, this can be thought of as widening the distribution tails.
The look forward parameter is currently fixed at 20, this is because it does not currently work correctly with higher integers, I will try resolve this problem and any other bugs as soon as possible
The Indicator combines volatility and frequency distributions to forecast an area of possible price expansion with an approximate confidence interval / level and level of significance (significance level).
The Script Formula
Additional comments
To alter the models forecasting precision to reflect a given confidence interval, e.g the 90% confidence level (C.L.), use the 1.64 multiplier (toggle value in "Standard normal distribution sd" setting), to use a specific C.L., e.g. the 85th percentile either search for this on google, or calculate it yourself using a Standard Normal Distribution Probability table. Additionaly volatility may be changed by toggling the lookback period setting, this can be thought of as widening the distribution tails.
The look forward parameter is currently fixed at 20, this is because it does not currently work correctly with higher integers, I will try resolve this problem and any other bugs as soon as possible
發行說明
- Fixed forecast limit to chart maximum = 100 bars of x unit time in future. Script now uses polyline
chart.point
- Price labels for chart maximum and chart minimum forecasts
- Different Forecasting types (Price, Normal, Log-Normal (this is the exponential of the normal distribution)
Model Assumptions:
For “Price”
- Normal distribution of residuals (difference between source and moving average at time i where moving average is constant)
- Independence of residuals (i.e. we assume residuals are iid)
- Stationarity of time series (we assume that the mean = moving average and variance is remains constant over the forecast horizon)
For “Normal” and “Log-Normal” forecasting type
- Log-Normal distribution of residuals (difference between log returns and mean sample log returns at time i where sample mean is constant over lookback period)
- Independence of residuals (i.e. we assume residuals are iid)
- Stationarity of drift (mu) and log returns (sigma)
Comments on the Log-Normal Forecast Model
Simulating asset-prices assuming a log-normal distribution is preferred as it models real life scenarios most accurately, e.g. it caters to the fact of non-negative prices, positive skewness and multiplicativity, assumptions that the other models fail to make.
If we were to simulate asset prices via GBM (geometric brownian motion) using the same mean and variance parameters as in our residual standard deviation and simulate n paths, we would expect the price to remain within the confidence interval (by assumption) approximately C.I amount of the time where C.I. is the confidence level corresponding to the Z score used in the residual standard deviation of log returns(e.g. a 90% C.I. means 90% of all sampled values will be less than or as extreme as the corresponding Z score value, in this case 1.64). In other words only (1 - C.I.)% of the time would we expect a more extreme prediction. This is because GBM assumes normally distributed log returns, constant drift and volatility.
Let's take the following example, we have a 95% C.I., so we expect only 5% of simulated GBM paths to lie outside our confidence interval. We can see this in action below. note by law of large numbers, the limit as n (number of simulated paths) tends to infinity of the probability that the number of values that lie within the confidence interval will tend towards its theoretical maximum identical to our C.I.
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。
開源腳本
秉持TradingView一貫精神,這個腳本的創作者將其設為開源,以便交易者檢視並驗證其功能。向作者致敬!您可以免費使用此腳本,但請注意,重新發佈代碼需遵守我們的社群規範。
免責聲明
這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。