1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
43 lines of Pine Script v5 from tv-scripts/tvt-vix-term-structure.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
tvt-vix-term-structure.pine
//@version=5
indicator(title="[TVT] VIX Term Structure", shorttitle="[TVT] VIX-TS", overlay=false)
// Input parameters
ma_length = input.int(3, title="MA Length", minval=1)
ma_type = input.string("EMA", title="MA Type", options=["EMA", "SMA"])
// Plot toggles
show_ma_9d = input.bool(true, title="Show MA VIX9D")
show_ma_vix = input.bool(true, title="Show MA VIX")
show_ma_3m = input.bool(true, title="Show MA VIX3M")
show_ma_6m = input.bool(true, title="Show MA VIX6M")
// Fetch VIX data using chart's timeframe
vix9d = request.security("VIX9D", timeframe.period, close)
vix = request.security("VIX", timeframe.period, close)
vix3m = request.security("VIX3M", timeframe.period, close)
vix6m = request.security("VIX6M", timeframe.period, close)
// Function to calculate MA based on type
calcMA(source, length) =>
ma_type == "EMA" ? ta.ema(source, length) : ta.sma(source, length)
// Calculate MAs
ma9d = calcMA(vix9d, ma_length)
maVix = calcMA(vix, ma_length)
ma3m = calcMA(vix3m, ma_length)
ma6m = calcMA(vix6m, ma_length)
// Define colors with transparency
purple_transp = color.new(color.purple, 50)
blue_transp = color.new(color.blue, 50)
green_transp = color.new(color.green, 50)
orange_transp = color.new(color.orange, 50)
yellow_transp = color.new(color.yellow, 50)
red_transp = color.new(color.red, 50)
// Plot either raw VIX or MA based on toggles
plot(show_ma_9d ? ma9d : vix9d, title="VIX9D", color=purple_transp, style=plot.style_line, linewidth=2)
plot(show_ma_vix ? maVix : vix, title="VIX", color=blue_transp, style=plot.style_line, linewidth=2)
plot(show_ma_3m ? ma3m : vix3m, title="VIX3M", color=green_transp, style=plot.style_line, linewidth=2)
plot(show_ma_6m ? ma6m : vix6m, title="VIX6M", color=orange_transp, style=plot.style_line, linewidth=2)
Overview
VIX Term Structure requests close data for four Cboe volatility indexes: VIX9D (9-day), VIX (30-day), VIX3M (3-month), and VIX6M (6-month) on the current timeframe. For each index, it calculates either an exponential or simple moving average with a customizable length. Users can independently toggle whether to display the smoothed moving average or the raw close price for each maturity, helping track contango and backwardation conditions across volatility tenors.
Multi-tenor VIX comparison (9D, 30D, 3M, 6M)
Selectable EMA or SMA smoothing
Independent display toggles for raw or smoothed lines
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
MA Length
int
3
ma_length
MA Type
string
EMA
ma_type
Show MA VIX9D
bool
true
show_ma_9d
Show MA VIX
bool
true
show_ma_vix
Show MA VIX3M
bool
true
show_ma_3m
Show MA VIX6M
bool
true
show_ma_6m
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us
MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a
The AMFM indicator decomposes price movements into amplitude and frequency components using Ehlers' digital signal processing methods. It whitens the derivative as close minus open, then computes AM as the smoothed envelope of the absolute difference over 4 pe
PPO ATR Bands plots a percentage price oscillator in a separate pane. It compares a Hull average of typical price with a volume-weighted exponential average of Parabolic SAR, then scales three true-range bands around the slow average into matching oscillator l
The 8-Factor Composite Screener evaluates equities across fundamental and technical criteria, including valuation ratios, earnings and revenue growth, 12-month return momentum, proximity to 52-week highs, Stage 2 moving average alignment, benchmark relative st
This indicator plots a relative strength index in a separate pane. It calculates RSI from the average of the previous ten opens rather than the current bar, so that source does not change during the live candle. A moving average of the RSI is plotted and can b