MVRV Z-ScoreThe MVRV ratio was created by Murad Mahmudov & David Puell. It simply compares Market Cap to Realised Cap, presenting a ratio (MVRV = Market Cap / Realised Cap). The MVRV Z-Score is a later version, refining the metric by normalising the peaks and troughs of the data.
Realized
vol_coneDraws a volatility cone on the chart, using the contract's realized volatility (rv). The inputs are:
- window: the number of past periods to use for computing the realized volatility. VIX uses 30 calendar days, which is 21 trading days, so 21 is the default.
- stdevs: the number of standard deviations that the cone will cover.
- periods to project: the length of the volatility cone.
- periods per year: the number of periods in a year. for a daily chart, this is 252. for a thirty minute chart on a contract that trades 23 hours a day, this is 23 * 2 * 252 = 11592. for an accurate cone, this input must be set correctly, according to the chart's time frame.
- history: show the lagged projections. in other words, if the cone is set to project 21 periods in the future, the lines drawn show the top and bottom edges of the cone from 23 periods ago.
- rate: the current interest or discount rate. this is used to compute the forward price of the underlying contract. using an accurate forward price allows you to compare the realized volatility projection to the implied volatility projections derived from options prices.
Example settings for a 30 minute chart of a contract that trades 23 hours per day, with 1 standard deviation, a 21 day rv calculation, and half a day projected:
- stdevs: 1
- periods to project: 23
- window: 23 * 2 * 21 = 966
- periods per year: 23 * 2 * 252 = 11592
Additionally, a table is drawn in the upper right hand corner, with several values:
- rv: the contract's current realized volatility.
- rnk: the rv's percentile rank, compared to the rv values on past bars.
- acc: the proportion of times price settled inside, versus outside, the volatility cone, "periods to project" into the future. this should be around 65-70% for most contracts when the cone is set to 1 standard deviation.
- up: the upper bound of the cone for the projection period.
- dn: the lower bound of the cone for the projection period.
Limitations:
- pinescript only seems to be able to draw a limited distance into the future. If you choose too many "periods to project", the cone will start drawing vertically at some limit.
- the cone is not totally smooth owing to the facts a) it is comprised of a limited number of lines and b) each bar does not represent the same amount of time in pinescript, as some cross weekends, session gaps, etc.
vol_boxA simple script to draw a realized volatility forecast, in the form of a box. The script calculates realized volatility using the EWMA method, using a number of periods of your choosing. Using the "periods per year", you can adjust the script to work on any time frame. For example, if you are using an hourly chart with bitcoin, there are 24 periods * 365 = 8760 periods per year. This setting is essential for the realized volatility figure to be accurate as an annualized figure, like VIX.
By default, the settings are set to mimic CBOE volatility indices. That is, 252 days per year, and 20 period window on the daily timeframe (simulating a 30 trading day period).
Inside the box are three figures:
1. The current realized volatility.
2. The rank. E.g. "10%" means the current realized volatility is less than 90% of realized volatility measures.
3. The "accuracy": how often price has closed within the box, historically.
Inputs:
stdevs: the number of standard deviations for the box
periods to project: the number of periods to forecast
window: the number of periods for calculating realized volatility
periods per year: the number of periods in one year (e.g. 252 for the "D" timeframe)
vol_bracketThis simple script shows an "N" standard deviation volatility bracket, anchored at the opening price of the current month, week, or quarter. This anchor is meant to coincide roughly with the expiration of options issued at the same interval. You can choose between a manually-entered IV or the hv30 volatility model.
Unlike my previous scripts, which all show the volatility bracket as a rolling figure, the anchor helps to visualize the volatility estimate in relation to price as it ranges over the (approximate) lifetime of a single, real contract.
Realized Variables for Options ComparisonThese variables can be used in comparison with the implied volatility of options.
Variables:
Realized Volatility
mathematical notation lowercase 'sigma'
Realized Variance
mathematical notation lowercase 'sigma' squared
Realized Beta
mathematical notation lowercase 'beta'
Timeframes:
Yearly = 250 or 365
Quarterly = 50 or 90
Monthly = 20 or 30
Important Note:
Options Contract Expiry = barmerge.lookahead_on
"Merge strategy for the requested data position. Requested barset is merged with current barset in the order of sorting bars by their opening time. This merge strategy can lead to undesirable effect of getting data from "future" on calculation on history. This is unacceptable in backtesting strategies, but can be useful in indicators."
[ All other timeframes barmerge.lookahead is disabled.
Realized VolatilityRealized / Historical Volatility
Calculates historical, i.e. realized volatility of any underlying. If frequency is not the daily, but for example 6h, 30min, weeks or months, it scales the initial setting to be suitable for the different time frame.
Examples with default settings (30 day volatility, 365 days per year):
A) Frequency = Daily:
Returns 30 day historical volatility, under the assumption that there are 365 trading days in a year.
B) Frequency = 6h:
Still returns 30 day historical volatility, under the assumption that there are 365 trading days in a year. However, since 6h granularity fits 4 times in 24 hours, it rescales the look back period to rather 30*4 = 120 units to still reflect 30 day historical volatility.
OHLC Volatility Estimators by @Xel_arjonaDISCLAIMER:
The Following indicator/code IS NOT intended to be a formal investment advice or recommendation by the author, nor should be construed as such. Users will be fully responsible by their use regarding their own trading vehicles/assets.
The embedded code and ideas within this work are FREELY AND PUBLICLY available on the Web for NON LUCRATIVE ACTIVITIES and must remain as is by Creative-Commons as TradingView's regulations. Any use, copy or re-use of this code should mention it's origin as it's authorship.
WARNING NOTICE!
THE INCLUDED FUNCTION MUST BE CONSIDERED AS DEBUGING CODE The models included in the function have been taken from openly sources on the web so they could have some errors as in the calculation scheme and/or in it's programatic scheme. Debugging are welcome.
WHAT'S THIS?
Here's a full collection of candle based (compressed tick) Volatility Estimators given as a function, openly available for free, it can print IMPLIED VOLATILITY by an external symbol ticker like INDEX:VIX.
Models included in the volatility calculation function:
CLOSE TO CLOSE: This is the classic estimator by rule, sometimes referred as HISTORICAL VOLATILITY and is the must common, accepted and widely used out there. Is based on traditional Standard Deviation method derived from the logarithm return of current close from yesterday's.
ELASTIC WEIGHTED MOVING AVERAGE: This estimator has been used by RiskMetriks®. It's calculation is based on an ElasticWeightedMovingAverage Standard Deviation method derived from the logarithm return of current close from yesterday's. It can be viewed or named as an EXPONENTIAL HISTORICAL VOLATILITY model.
PARKINSON'S: The Parkinson number, or High Low Range Volatility, developed by the physicist, Michael Parkinson, in 1980 aims to estimate the Volatility of returns for a random walk using the high and low in any particular period. IVolatility.com calculates daily Parkinson values. Prices are observed on a fixed time interval. n=10, 20, 30, 60, 90, 120, 150, 180 days.
ROGERS-SATCHELL: The Rogers-Satchell function is a volatility estimator that outperforms other estimators when the underlying follows a Geometric Brownian Motion (GBM) with a drift (historical data mean returns different from zero). As a result, it provides a better volatility estimation when the underlying is trending. However, this Rogers-Satchell estimator does not account for jumps in price (Gaps). It assumes no opening jump. The function uses the open, close, high, and low price series in its calculation and it has only one parameter, which is the period to use to estimate the volatility.
YANG-ZHANG: Yang and Zhang were the first to derive an historical volatility estimator that has a minimum estimation error, is independent of the drift, and independent of opening gaps. This estimator is maximally 14 times more efficient than the close-to-close estimator.
LOGARITHMIC GARMAN-KLASS: The former is a pinescript transcript of the model defined as in iVolatility . The metric used is a combination of the overnight, high/low and open/close range. Such a volatility metric is a more efficient measure of the degree of volatility during a given day. This metric is always positive.