There are multiple ways to estimate . Other than the traditional close-to-close estimator. This indicator provides different range-based estimators that take high low open into account for calculation and estimators that use other statistics measurements instead of standard deviation.
The gradient coloring and stats panel provides an overview of how high or low the current is compared to its historical values.
We have mentioned the concepts of in our previous indicators, Historical Volatility, Historical Volatility Rank, and Historical Volatility Percentile. You can check the definition of these scripts. The basic calculation is just the sample standard deviation of log return scaled with the square root of time. The main focus of this script is the difference between models.
Close-to-Close HV Estimator:
Close-to-Close is the traditional calculation. It uses sample standard deviation.
Note: the TradingView build in value is a bit off because it uses population standard deviation instead of sample deviation. N – 1 should be used here to get rid of the sampling bias.
• Close-to-Close HV estimators are the most commonly used estimators in finance. The calculation is straightforward and easy to understand. When people reference , most of the time they are talking about the close to close estimator.
• The Close-to-close estimator only calculates based on the closing price. It does not take account into intraday drift such as high, low. It also does not take account into the jump when open and close prices are not the same.
• Close-to-Close weights past equally during the lookback period, while there are other ways to weight the historical data.
• Close-to-Close is calculated based on standard deviation so it is vulnerable to returns that are not normally distributed and have fat tails. Mean and Median absolute
deviation makes the more stable with extreme values.
For more details about the Following Estimators, click into the blue text to read the original published paper:
Parkinson Hv Estimator:
• Parkinson was one of the first to come up with improvements to calculation.
• Parkinson suggests using the High and Low of each bar can represent better as it takes into account intraday . So Parkinson HV is also known as Parkinson High Low HV.
• It is about 5.2 times more efficient than Close-to-Close estimator. But it does not take account into jumps and drift. Therefore, it underestimates .
Note: By Dividing the Parkinson by Close-to-Close you can get a similar result to Variance Ratio Test. It is called the Parkinson number. It can be used to test if the market follows a random walk. (It is mentioned in Nassim Taleb's Dynamic Hedging book but it seems like he made a mistake and wrote the ratio wrongly.)
• Garman Klass expanded on Parkinson’s Estimator. Instead of Parkinson’s estimator using high and low, Garman Klass’s method uses open, close, high, and low to find the minimum variance method.
• The estimator is about 7.4 more efficient than the traditional estimator. But like Parkinson HV, it ignores jumps and drifts. Therefore, it underestimates .
• Rogers and Satchell found some drawbacks in Garman-Klass’s estimator. The Garman-Klass assumes price as Brownian motion with zero drift.
• The Rogers Satchell Estimator calculates based on open, close, high, and low. And it can also handle drift in the financial series.
• Rogers-Satchell HV is more efficient than Garman-Klass HV when there’s drift in the data. However, it is a little bit less efficient when drift is zero. The estimator doesn’t handle jumps, therefore it still underestimates .
Garman-Klass Yang-Zhang extension:
• Yang Zhang expanded Garman Klass HV so that it can handle jumps. However, unlike the Rogers-Satchell estimator, this estimator cannot handle drift. It is about 8 times more efficient than the traditional estimator.
• The Garman-Klass Yang-Zhang extension HV has the same value as Garman-Klass when there’s no gap in the data such as in cryptocurrencies.
• The Yang Zhang Estimator combines Garman-Klass and Rogers-Satchell Estimator so that it is based on Open, close, high, and low and it can also handle non-zero drift. It also expands the calculation so that the estimator can also handle overnight jumps in the data.
• This estimator is the most powerful estimator among the range-based estimators. It has the minimum variance error among them, and it is 14 times more efficient than the close-to-close estimator. When the overnight and daily are correlated, it might underestimate a little.
• 1.34 is the optimal value for alpha according to their paper. The alpha constant in the calculation can be adjusted in the settings.
Note: There are already some estimators coded on TradingView. Some of them are right, some of them are wrong. But for Yang Zhang Estimator I have not seen a correct version on TV.
EWMA Estimator: (Page 77)
• EWMA stands for Exponentially . The Close-to-Close and all other estimators here are all equally weighted.
• EWMA weighs more recent more and older less. The benefit of this is that is usually autocorrelated. The autocorrelation has close to exponential decay as you can see using an Autocorrelation Function indicator on absolute or squared returns. The autocorrelation causes clustering which values the recent more. Therefore, exponentially weighted can suit the property of well.
• RiskMetrics uses 0.94 for lambda which equals 30 lookback period. In this indicator Lambda is coded to adjust with the lookback. It's also easy for EWMA to forecast one period ahead.
• However, EWMA is not often used because there are better options to weight such as ARCH and GARCH.
Adjusted Mean Absolute Deviation Estimator:
• This estimator does not use standard deviation to calculate . It uses the distance log return is from its moving average as .
• It’s a simple way to calculate and it’s effective. The difference is the estimator does not have to square the log returns to get the . The paper suggests this estimator has more predictive power.
• The mean absolute deviation here is adjusted to get rid of the bias. It scales the value so that it can be comparable to the other estimators.
• In Nassim Taleb’s paper, he mentions people sometimes confuse MAD with standard deviation for measurements. And he suggests people use mean absolute deviation instead of standard deviation when we talk about .
Adjusted Median Absolute Deviation Estimator:
• This is another estimator that does not use standard deviation to measure .
• Using the median gives a more robust estimator when there are extreme values in the returns. It works better in fat-tailed distribution.
• The median absolute deviation is adjusted by maximum likelihood estimation so that its value is scaled to be comparable to other estimators.
• You can select the estimator models in the Model input
• is annualized. You can type in the numbers of trading days in a year in the Annual input based on the asset you are trading.
• Alpha is used to adjust the Yang Zhang estimator value.
• Percentile Length is used to Adjust Percentile coloring lookbacks.
• The gradient coloring will be based on the percentile value (0- 100). The higher the percentile value, the warmer the color will be, which indicates high . The lower the percentile value, the colder the color will be, which indicates low .
• When percentile coloring is off, it won’t show the gradient color.
• You can also use invert color to make the high a cold color and a low high color.
has some mean reversion properties. Therefore when is very low, and color is close to aqua, you would expect it to expand soon. When is very high, and close to red, you would it expect it to contract and cool down.
• When the background signal is on, it gives a signal when HVP is very low. Warning there might be a expansion soon.
• You can choose the plot style, such as lines, columns, areas in the plotstyle input.
• When the show information panel is on, a small panel will display on the right.
• The information panel displays the model name, the 50th percentile of HV, and HV percentile.
50 the percentile of HV also means the median of HV. You can compare the value with the current HV value to see how much it is above or below so that you can get an idea of how high or low HV is.
HV Percentile value is from 0 to 100. It tells us the percentage of periods over the entire lookback that traded below the current level. Higher HVP, higher HV compared to its historical data. The gradient color is also based on this value.
█ HOW TO USE
If you haven’t used the hvp indicator, we suggest you use the HVP indicator first. This indicator is more like with HVP coloring. So it displays HVP values in the color and panel, but it’s not range bound like the HVP and it displays HV values.
The user can have a quick understanding of how high or low the current is compared to its historical value based on the gradient color. They can also time the market better based on mean reversion. High means contracts soon (Move about to End, Market will cooldown), low means expansion soon (Market About to Move).
█ FINAL THOUGHTS
HV vs ATR
The above estimator concepts are a display of history in the quantitative finance realm of the research of estimations. It's a timeline of range based from the Parkinson to Yang Zhang . We hope these descriptions make more people know that even though ATR is the most popular indicator in , it's not the best estimator. Almost no one in quant finance uses ATR to measure (otherwise these papers will be based on how to improve ATR measurements instead of HV). As you can see, there are much more advanced estimators that also take account into open, close, high, and low. HV values are based on log returns with some calculation adjustment. It can also be scaled in terms of price just like ATR. And for profit-taking ranges, ATR is not based on probabilities. can be used in a probability distribution function to calculated the probability of the ranges such as the Expected Move indicator.
There are also other more advanced estimators. There are high frequency sampled HV that uses intraday data to calculate . We will publish the high frequency estimator in the future. There's also ARCH and GARCH models that takes clustering into account. GARCH models require maximum likelihood estimation which needs a solver to find the best weights for each component. This is currently not possible on TV due to large computational power requirements. All the other indicators claims to be GARCH are all wrong.
Special Thanks to midtownsk8rguy for applying/employing Pine etiquette.
Với tinh thần của TradingView, tác giả đã xuất bản tập lệnh theo mã nguồn mở, vì thế trader có thể dễ dàng hiểu và tùy chỉnh được. Bạn có thể sử dụng miễn phí, hoặc tùy chỉnh lại mã đã được cấp phép bởi Quy tắc Chung. Bạn có thể sử dụng nó trên biểu đồ.
thank you for being so kind sharing the code with us, with extensive documentations attached. You definitely spent a lot of time researching, definitely an example for novice trader like me to look up to.