INVITE-ONLY SCRIPT
已更新 Hierarchical Hidden Markov Model - Probability Cone

The Hierarchical Hidden Markov Model - Probability Cone Indicator utilizes Hierarchical Hidden Markov Models (HHMMs) to forecast future price movements in financial markets. The hierarchical structure allows HHMMs to capture longer-term dependencies and more complex patterns in time series data compared to standard HMMs. The indicator uses HHMMs to model and predict future states and their associated outputs based on the current state and model parameters. These models are comprised of three main components: transition and termination probabilites, emission probabilities, and initial probabilities. Transition probabilities determine the likelihood of moving from one state to another. Emission probabilities indicate the likelihood of observing a specific output given a state (e.g., log return). Initial probabilities describe the overall probability distribution of the states in the model (i.e., long-run probabilities).
To estimate the probability cone forecast, the indicator integrates two primary methodologies: Gaussian approximation and importance sampling with Monte Carlo. The Gaussian approximation is utilized for estimating the central 90% of future prices. This method provides a quick and efficient estimation within this central range, capturing the most likely price movements. The Gaussian approximation results in a forecast with an equal mean and variance as the true forecast, but it may not accurately reflect higher moments like skewness and kurtosis. Therefore, the tail quantiles, which represent extreme price movements beyond the central range (90%), are estimated via importance sampling. This approach ensures a more accurate estimation of the skewness and kurtosis associated with extreme scenarios. While importance sampling leverages the flexibility of Monte Carlo and attempts to increase its efficiency by sampling from more precise areas of the distribution, it may still underestimate the most extreme quantiles associated with the lowest probabilities, which is an inherent limitation of the indicator.
Example of gaussian approximation cone:

Example of importance sampling cone:

Settings:
- Source: Data source used for the model
- Forecast Period: Number of bars ahead for generating forecasts.
- Simulation Number: Number of Monte Carlo simulations to run in the case of importance sampling.
- Body Probability: Specifies the inner range of the probability cone. The probability specifies the amount of observations that are expected to fall outside of this range.
- Tail Probability: Specifies the outer range of the probability cone. When this probability is under 5%, importance sampling will turn on.
- Lock Cone: When ticked on, the cone will be locked at its current position.
- Offset Cone Based on Date: When ticked on, the position of the cone will be determined by the selected date.
- Offset: When "Offset Cone Based on Date" is turned off, you can use offset setting to specify the position of the cone projection.
- Date: When "Offset Cone Based on Date" is turned on, you can use the date setting to specify the date from which the forecast starts.
- Reestimate Model Every N Bars: This is especially useful if you wish to use the indicator on lower timeframes where model estimation might take longer than for the new datapoint to arrive. In that case you can specify after how many bars the model should be reestimated.
- Training Period: Length of historical data used to train the HMM.
- Expectation Maximization Iterations: Number of iterations for the EM algorithm.
- Cone Colors: Customizable colors for the probability cone, when approximation is on and when importance sampling is on
To estimate the probability cone forecast, the indicator integrates two primary methodologies: Gaussian approximation and importance sampling with Monte Carlo. The Gaussian approximation is utilized for estimating the central 90% of future prices. This method provides a quick and efficient estimation within this central range, capturing the most likely price movements. The Gaussian approximation results in a forecast with an equal mean and variance as the true forecast, but it may not accurately reflect higher moments like skewness and kurtosis. Therefore, the tail quantiles, which represent extreme price movements beyond the central range (90%), are estimated via importance sampling. This approach ensures a more accurate estimation of the skewness and kurtosis associated with extreme scenarios. While importance sampling leverages the flexibility of Monte Carlo and attempts to increase its efficiency by sampling from more precise areas of the distribution, it may still underestimate the most extreme quantiles associated with the lowest probabilities, which is an inherent limitation of the indicator.
Example of gaussian approximation cone:
Example of importance sampling cone:
Settings:
- Source: Data source used for the model
- Forecast Period: Number of bars ahead for generating forecasts.
- Simulation Number: Number of Monte Carlo simulations to run in the case of importance sampling.
- Body Probability: Specifies the inner range of the probability cone. The probability specifies the amount of observations that are expected to fall outside of this range.
- Tail Probability: Specifies the outer range of the probability cone. When this probability is under 5%, importance sampling will turn on.
- Lock Cone: When ticked on, the cone will be locked at its current position.
- Offset Cone Based on Date: When ticked on, the position of the cone will be determined by the selected date.
- Offset: When "Offset Cone Based on Date" is turned off, you can use offset setting to specify the position of the cone projection.
- Date: When "Offset Cone Based on Date" is turned on, you can use the date setting to specify the date from which the forecast starts.
- Reestimate Model Every N Bars: This is especially useful if you wish to use the indicator on lower timeframes where model estimation might take longer than for the new datapoint to arrive. In that case you can specify after how many bars the model should be reestimated.
- Training Period: Length of historical data used to train the HMM.
- Expectation Maximization Iterations: Number of iterations for the EM algorithm.
- Cone Colors: Customizable colors for the probability cone, when approximation is on and when importance sampling is on
版本注释
- minor changes版本注释
-免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。