Realized volatility differentialAbout
This is a simple indicator that takes into account two types of realized volatility: Close-Close and High-Low (the latter is more useful for intraday trading).
The output of the indicator is two values / plots:
an average of High-Low volatility minus Close-Close volatility (10day period is used as a default)
the current value of the indicator
When the current value is:
lower / below the average, then it means that High-Low volatility should increase.
higher / above then obviously the opposite is true.
How to use it
It might be used as a timing tool for mean reversion strategies = when your primary strategy says a market is in mean reversion mode, you could use it as a signal for opening a position.
For example: let's say a security is in uptrend and approaching an important level (important to you).
If the current value is:
above the average, a short position can be opened, as High-Low volatility should decrease;
below the average, a trend should continue.
Intended securities
Futures contracts
Realizedvolatility
Inter-Exchanges Crypto Price Spread Clouds (Tartigradia)Display variations in min-max and median values of high, low and close across exchanges. It's a kind of realized volatility indicator, as the idea is that in times of high volatility (high emotions, fear, uncertainty), it's more likely that market inefficiencies will appear for the same asset between different market makers, ie, the price can temporarily differ a lot. This indicator will catch these instants of high differences between exchanges, even if they lasted only an instant (because we use high and low values).
Compared with my other "Inter-Exchanges Crypto Price Spread Deviation" indicator, this one overlays directly on the chart, and offers a different take based on the same premisses. Instead of summarizing volatility via standard deviation, here we display clouds of the range of values that were observed.
A big advantage of this approach is that it can also be used to determine safe stop loss levels, especially the values of percentile rank (i.e., what are the high values that were observed in at least 50% of exchanges?).
Indeed, all price levels are displayed in the indicator's status bar:
green for high values,
red for low values,
aqua for median,
purple for average,
The first two values are max and min values of high across exchanges (in green).
The next two values are max and min of low across exchanges (in red).
The next two values are median (aqua) and average (purple).
The last two values are percentile rank values for high (green) and low (red) respectively.
Another advantage is that the high (green) vs low (red) clouds can be seen as representing the buying or selling pressure respectively across exchanges, and this may in itself provide a signal to know whether one side is winning.
Link to my other complementary indicator:
Compared to other inter-exchanges spread indicators, this one offers two major features:
The symbol automatically adapts to the symbol currently selected in user's chart. Hence, switching between tickers does not require the user to modify any option, everything is dynamically updated behind the scenes.
It's easy to add more exchanges (requires some code editing because PineScript v5 does not allow dynamical request.security() calls).
Limitations/things to know:
History is limited to what the ticker itself display. Ie, even if the exchanges specified in this indicator have more data than the ticker currently displayed in the user's chart, the indicator will show only a timeperiod as long as the chart.
The indicator can manage multiple exchanges of different historical length (ie, some exchanges having more data going way earlier in the past than others), in which case they will simply be ignored from calculations when far back in the past. Hence, you should be aware that the further you go in the past, the less exchanges will have such data, and hence the less accurate the measures will be (because the deviation will be calculated from less sources than more recent bars). This is thanks to how the array.* math functions behave in case of na values, they simply skip them from calculations, contrary to math.* functions.
Inter-Exchanges Crypto Price Spread Deviation (Tartigradia)Measures the deviation of price metrics between various exchanges. It's a kind of realized volatility indicator, as the idea is that in times of high volatility (high emotions, fear, uncertainty), it's more likely that market inefficiencies will appear for the same asset between different market makers, ie, the price can temporarily differ a lot. This indicator will catch these instants of high differences between exchanges, even if they lasted only an instant (because we use high and low values).
Both standard deviation and median absolute deviation (more robust to outliers, ie, exchanges with a very different price from others won't influence the median absolute deviation, but the standard deviation yes).
Compared to other inter-exchanges spread indicators, this one offers two major features:
* The symbol automatically adapts to the symbol currently selected in user's chart. Hence, switching between tickers does not require the user to modify any option, everything is dynamically updated behind the scenes.
* It's easy to add more exchanges (requires some code editing because PineScript v5 does not allow dynamical request.security() calls).
Limitations/things to know:
* History is limited to what the ticker itself display. Ie, even if the exchanges specified in this indicator have more data than the ticker currently displayed in the user's chart, the indicator will show only a timeperiod as long as the chart.
* The indicator can manage multiple exchanges of different historical length (ie, some exchanges having more data going way earlier in the past than others), in which case they will simply be ignored from calculations when far back in the past. Hence, you should be aware that the further you go in the past, the less exchanges will have such data, and hence the less accurate the measures will be (because the deviation will be calculated from less sources than more recent bars). This is thanks to how the array.* math functions behave in case of na values, they simply skip them from calculations, contrary to math.* functions.
Implied Volatility Estimator using Black Scholes [Loxx]Implied Volatility Estimator using Black Scholes derives a estimation of implied volatility using the Black Scholes options pricing model. The Bisection algorithm is used for our purposes here. This includes the ability to adjust for dividends.
Implied Volatility
The implied volatility (IV) of an option contract is that value of the volatility of the underlying instrument which, when input in an option pricing model (such as Black–Scholes), will return a theoretical value equal to the current market price of that option. The VIX , in contrast, is a model-free estimate of Implied Volatility. The latter is viewed as being important because it represents a measure of risk for the underlying asset. Elevated Implied Volatility suggests that risks to underlying are also elevated. Ordinarily, to estimate implied volatility we rely upon Black-Scholes (1973). This implies that we are prepared to accept the assumptions of Black Scholes (1973).
Inputs
Spot price: select from 33 different types of price inputs
Strike Price: the strike price of the option you're wishing to model
Market Price: this is the market price of the option; choose, last, bid, or ask to see different results
Historical Volatility Period: the input period for historical volatility ; historical volatility isn't used in the Bisection algo, this is to serve as a comparison, even though historical volatility is from price movement of the underlying asset where as implied volatility is the volatility of the option
Historical Volatility Type: choose from various types of implied volatility , search my indicators for details on each of these
Option Base Currency: this is to calculate the risk-free rate, this is used if you wish to automatically calculate the risk-free rate instead of using the manual input. this uses the 10 year bold yield of the corresponding country
% Manual Risk-free Rate: here you can manually enter the risk-free rate
Use manual input for Risk-free Rate? : choose manual or automatic for risk-free rate
% Manual Yearly Dividend Yield: here you can manually enter the yearly dividend yield
Adjust for Dividends?: choose if you even want to use use dividends
Automatically Calculate Yearly Dividend Yield? choose if you want to use automatic vs manual dividend yield calculation
Time Now Type: choose how you want to calculate time right now, see the tool tip
Days in Year: choose how many days in the year, 365 for all days, 252 for trading days, etc
Hours Per Day: how many hours per day? 24, 8 working hours, or 6.5 trading hours
Expiry date settings: here you can specify the exact time the option expires
*** the algorithm inputs for low and high aren't to be changed unless you're working through the mathematics of how Bisection works.
Included
Option pricing panel
Loxx's Expanded Source Types
Related Indicators
Cox-Ross-Rubinstein Binomial Tree Options Pricing Model
rv_iv_vrpThis script provides realized volatility (rv), implied volatility (iv), and volatility risk premium (vrp) information for each of CBOE's volatility indices. The individual outputs are:
- Blue/red line: the realized volatility. This is an annualized, 20-period moving average estimate of realized volatility--in other words, the variability in the instrument's actual returns. The line is blue when realized volatility is below implied volatility, red otherwise.
- Fuchsia line (opaque): the median of realized volatility. The median is based on all data between the "start" and "end" dates.
- Gray line (transparent): the implied volatility (iv). According to CBOE's volatility methodology, this is similar to a weighted average of out-of-the-money ivs for options with approximately 30 calendar days to expiration. Notice that we compare rv20 to iv30 because there are about twenty trading periods in thirty calendar days.
- Fuchsia line (transparent): the median of implied volatility.
- Lightly shaded gray background: the background between "start" and "end" is shaded a very light gray.
- Table: the table shows the current, percentile, and median values for iv, rv, and vrp. Percentile means the value is greater than "N" percent of all values for that measure.
-----
Volatility risk premium (vrp) is simply the difference between implied and realized volatility. Along with implied and realized volatility, traders interpret this measure in various ways. Some prefer to be buying options when there volatility, implied or realized, reaches absolute levels, or low risk premium, whereas others have the opposite opinion. However, all volatility traders like to look at these measures in relation to their past values, which this script assists with.
By the way, this script is similar to my "vol premia," which provides the vrp data for all of these instruments on one page. However, this script loads faster and lets you see historical data. I recommend viewing the indicator and the corresponding instrument at the same time, to see how volatility reacts to changes in the underlying price.
vol_premiaThis script shows the volatility risk premium for several instruments. The premium is simply "IV30 - RV20". Although Tradingview doesn't provide options prices, CBOE publishes 30-day implied volatilities for many instruments (most of which are VIX variations). CBOE calculates these in a standard way, weighting at- and out-of-the-money IVs for options that expire in 30 days, on average. For realized volatility, I used the standard deviation of log returns. Since there are twenty trading periods in 30 calendar days, IV30 can be compared to RV20. The "premium" is the difference, which reflects market participants' expectation for how much upcoming volatility will over- or under-shoot recent volatility.
The script loads pretty slow since there are lots of symbols, so feel free to delete the ones you don't care about. Hopefully the code is straightforward enough. I won't list the meaning of every symbols here, since I might change them later, but you can type them into tradingview for data, and read about their volatility index on CBOE's website. Some of the more well-known ones are:
ES: S&P futures, which I prefer to the SPX index). Its implied volatility is VIX.
USO: the oil ETF representing WTI future prices. Its IV is OVX.
GDX: the gold miner's ETF, which is usually more volatile than gold. Its IV is VXGDX.
FXI: a china ETF, whose volatility is VXFXI.
And so on. In addition to the premium, the "percentile" column shows where this premium ranks among the previous 252 trading days. 100 = the highest premium, 0 = the lowest premium.
0_dteUSAGE
This script guages the probability of an underlying moving a certain amount on expiration day, to aid the popular "0 dte" strategy. The script counts how many next-day moves exceeded a given magnitude in the past, under similar conditions. The inputs are:
mark_mode:
- "open": measures the magnitude as "open to close"--a true 0 dte.
- "previous close": for lazy people who don't want to wake up early. measures magnitude from the previous day's close.
move_mode:
- "percent": measures moves that exceed a given percentage.
- "absolute": measures moves that exceed a point value.
move-dir: measure only up moves, down moves, or both.
vol_model: the model for realized volatility. (may add more later).
min_vol: only measure moves when realized vol is above this value.
max_vol: only measure moves when realized vol is below this value.
precision: number of digits printed in the output table.
EXAMPLE:
- mark_mode: "previous close"
- move_mode: "percent"
- move_dir: "up"
- move_mag: 0.07
- vol_model: hv30
- min_vol: 0.2
- max_vol: 0.5
These settings will count the number of trading days that closed 7% higher than the previous day's close, when the previous day's realized volatility (annualized) was between 20% and 50%. The outputs are:
- current vol: green plot. Today's realized vol. Shown for convenience.
- max and min vol: red plots. Also shown for convenience.
- count: the number of days that exceeded the chosen magnitude, when the previous day's realized volatility was within the chosen bounds.
- total: the total number of days where realized volatility was within the chosen bounds
- probability: count / total. the percentage of days that exceeded the move when volatility was within the bounds.
- move: plotted as a purple line. purple "X" labels are plotted above
- bars where the move exceeded the magnitude threshold and volatility was in-bounds. a "hit".
CONCLUSION
This script is based on the idea that realized volatility has some bearing on future volatility. By seeing what happened in the past when volatility was close to its current value, we may be able to assess the probability that our short put will be in the money, tomorrow, and our account devastated.
NOTE: Unlike many of my other scripts, all percentages--both inputs and outputs--are given in fractional form. E.g., 0.01 means 1%.