taylor_o

vol_ranges

taylor_o 업데이트됨   
This script shows three measures of volatility:

historical (hv): realized volatility of the recent past
median (mv): a long run average of realized volatility
implied (iv): a user-defined volatility

Historical and median volatility are based on the EWMA, rather than standard deviation, method of calculating volatility. Since Tradingview's built in ema function uses a window, the "window" parameter determines how much historical data is used to calculate these volatility measures. E.g. 30 on a daily chart means the previous 30 days.

The plots above and below historical candles show past projections based on these measures. The "periods to expiration" dictates how far the projection extends. At 30 periods to expiration (default), the plot will indicate the one standard deviation range from 30 periods ago. This is calculated by multiplying the volatility measure by the square root of time. For example, if the historical volatility (hv) was 20% and the window is 30, then the plot is drawn over: close * 1.2 * sqrt(30/252).

At the most recent candle, this same calculation is simply drawn as a line projecting into the future.

This script is intended to be used with a particular options contract in mind. For example, if the option expires in 15 days and has an implied volatility of 25%, choose 15 for the window and 25 for the implied volatility options. The ranges drawn will reflect the two standard deviation range both in the future (lines) and at any point in the past (plots) for HV (blue), MV (red), and IV (grey).
릴리즈 노트:
since iv is not based on historical data, removed the plots. this makes the output more legible.
릴리즈 노트:
Fixed a bug with the plots (not lines) which were using the window input (rather than periods to expiration). The plots are supposed to show the projected 2 SD range from "periods to expiration" ago. This allows you to see how often the current projection failed/succeeded in the past.
릴리즈 노트:
This is a substantial upgrade over the original script. I wish I could rename it to "vol_models". The idea is to test different volatility forecasts. Right now there are three volatility models:

historical (hv): a ema-derived volatility using a fixed window of historical returns.
median historical (mv): the median of a fixed-range of hv samples.
implied volatility (iv): a static implied volatility value that you derived elsewhere (e.g. copy/paste from your broker)

I hope to add more models in the future. The new features in this version are:

- Better comments and naming, to make the script more readable.
- The forecast plots are disabled by default. Use the settings to enable the ones you want to see.
- There is a table that shows how many periods price "breached" the forecast, as percentage and total. Every bar should have a forecast for hv and iv, but mv is limited to 4999 forecasts due to pinescript's limits.
- You can adjust the number of standard deviations to use in the forecast. This input replaces the 1 SD option from previous versions.
- The forecasts now use 365 days per year, not 252.
릴리즈 노트:
improvements in this version:

- theoretical values added to the table
- blended volatility model
- added a discount rate input
- (arguably) better names and comments, to make the code more readable

the theoretical values are computed by assuming a call was sold at a strike equal to each upper forecast, or a put at each lower forecast. If the closing price is above (below) the forecast, the contract is in the money; otherwise, it is worthless. the table shows the average value, at expiration, of a call ("t") or put ("b"), discounted to present value using the discount rate input.

the "blended volatility" (bv) is the more conservative of each historical (hv) and median historical (mv) forecast. for example, if the upper hv forecast is greater than the upper mv forecast, the upper bv forecast is equal to the upper hv forecast. there is no point drawing a line for this forecast, since it is obvious from looking at the hv and mv lines, but you can see the historical plots.
릴리즈 노트:
two main changes:

- normalized the theoretical values, which should make them much more accurate.
- changed some input defaults:
- range from 4999 to 365 (making it more compatible with most tickers)
- IV to 0, which the only default that is relevant for all tickers (since it shows the straddle)
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?