Indicator · Pine Script v5 · On the chart

TTP VIX Spy

by AubakirovArman

Pulls the VIX and builds a MACD histogram from it, then uses that with a SuperTrend, a band width test, price and RSI slope checks and an optional working-days filter to print B1, B2, S1 and S2 labels on the price chart.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code126
Settings9inputs
LicenceMIT
Last update3 months ago26 Jul 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

126 lines of Pine Script v5 from pine/7-ttp-vix-spy.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

7-ttp-vix-spy.pine
//@version=5
indicator(title="TTP VIX Spy", shorttitle="TTP VIX Spy v0.1", overlay = true)
import TradingView/ta/5
import mentalRock19315/Slope_TK/1 as TK

vixSec = request.security("TVC:VIX", timeframe.period, close)

// parameters
fast_length = 12
slow_length = 26
src = vixSec
signal_length = 9

// VIX MACD
fast_ma = ta.ema(src, fast_length)
slow_ma =  ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = ta.ema(macd, signal_length)
hist = macd - signal
col_grow_above = #26A69A
col_fall_above = #B2DFDB
col_grow_below = #FFCDD2
col_fall_below = #FF5252
histcolor = (hist>=0 ? (hist[1] < hist ? col_grow_above : col_fall_above) : (hist[1] < hist ? col_grow_below : col_fall_below))

// BBW
basis = ta.sma(close, 40)
dev = 2 * ta.stdev(close, 40)
upper = basis + dev
lower = basis - dev
bbw = (upper-lower)/basis
bbwcond = ta.barssince(bbw > 0.05) < 10

// vix
vixThresh = 0.0//input.float(0.0, step = 0.01)
vixConditionBuy = hist[1] < hist and hist < 0 and hist < -1 * vixThresh
vixConditionSell = hist[1] > hist and hist > 0 and hist >  vixThresh
vixConditionBuy2 = hist[1] < hist and hist > 0 
vixConditionSell2 = hist[1] > hist and hist < 0 

// supertrend
stfactor = input(6, "ST factor") 
stperiod = input(10, "ST period")
[supertrend, direction] = ta.supertrend(stfactor, stperiod)
downtrend = direction > 0
uptrend = not downtrend
mid = (open + close) / 2
bodyMiddle = plot(mid, "mid",display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = na, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = na, style=plot.style_linebr)
fill(bodyMiddle, upTrend,  supertrend, mid, color.new(histcolor, 80), color.new(color.black, 100),  fillgaps=false)
fill(bodyMiddle, downTrend, supertrend, mid, color.new(histcolor, 80), color.new(color.black, 100), fillgaps=false)


// slope
size = input.int(2,"slope lookback", minval=1)

// price
sma = ta.sma(close,14)
slopep = TK.slope(sma, size)
priceCondBuy = slopep < 0
priceCondSell = slopep > 0

// rsi vix
vixrsi= ta.rsi(vixSec, 14)
vixrsiCondBuy = vixrsi > 30
vixrsiCondSell = vixrsi < 70

// rsi
rsi = ta.rsi(close, 21)
rsima = ta.sma(rsi, 14)
slope = TK.slope(rsima, size)
rsicondBuy = slope > 0.5 
rsicondSell = slope < -0.5

// weekdays
timeIsAllowed = time(timeframe.period, "0000-0000:23456")

// SIGNAL
rsiOn = input(true, title = "Price RSI slope")
trendOn = input(true, title = "Counter trend")
bbwOn = input(true, "Wide BBW")
priceOn = input(true, "Price slope")
vixrsiOn = input(false, "VIX rsi filter")
weekOn = input(false, "Working days only")


buysignal = (rsicondBuy or not rsiOn) 
     and (downtrend or not trendOn) 
     and (bbwcond  or not bbwOn)
     and (priceCondBuy  or not priceOn)
     and( vixrsiCondBuy or not vixrsiOn)
     and (timeIsAllowed or not weekOn)


sellsignal =  (rsicondSell  or not rsiOn)
     and (uptrend   or not trendOn)
     and (bbwcond  or not bbwOn)
     and (priceCondSell  or not priceOn)
     and (vixrsiCondSell or not vixrsiOn)
     and (timeIsAllowed or not weekOn)

buysignal1 = buysignal and vixConditionBuy 
buysignal2 = buysignal and vixConditionBuy2 

sellsignal1 = sellsignal and vixConditionSell  
sellsignal2 = sellsignal and vixConditionSell2 

bgcolor(timeIsAllowed and weekOn ? color.new(color.blue, 90) : na)

plotshape(buysignal1, "B1", style = shape.labelup, location = location.belowbar, color = color.green, text= "B1", textcolor = color.white )
plotshape(sellsignal1, "S1", style = shape.labeldown, location = location.abovebar, color = color.red, text= "S1", textcolor = color.white )

plotshape(buysignal2, "B2", style = shape.labelup, location = location.belowbar, color = color.green, text= "B2", textcolor = color.white )
plotshape(sellsignal2, "S2", style = shape.labeldown, location = location.abovebar, color = color.red, text= "S2", textcolor = color.white )

plot(buysignal1 ? 1: na, "buy 1")
plot(sellsignal1 ? 1: na, "sell 1")

plot(buysignal2? 1: na, "buy 2")
plot(sellsignal2? 1: na, "sell 2")

alertcondition(buysignal1, "buy 1")
alertcondition(buysignal2, "buy 2")
alertcondition(sellsignal1, "sell 1")
alertcondition(sellsignal2, "sell 2")

Overview

The SuperTrend fill is coloured by the VIX histogram. Toggle inputs enable or disable each filter, and factor, period and slope lookback are adjustable. It is a signal overlay, with no stops or position sizing.

Details

Published by

AubakirovArman on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Trend, Oscillators & momentum, Volatility & bands

Markets

Indices, Stocks

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

backtestingbinanceblocklybybitchartingcryptono-codereactself-hostedtechnical-analysis

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
ST factorint6stfactor
ST periodint10stperiod
slope lookbackint2size
Price RSI slopebooltruersiOn
Counter trendbooltruetrendOn
Wide BBWbooltruebbwOn
Price slopebooltruepriceOn
VIX rsi filterboolfalsevixrsiOn
Working days onlyboolfalseweekOn
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.

Similar Pine Scripts

The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha

Indicator v5 Oscillators & momentumTrend
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup - Ankush Bajaj Momentum Investing Setup
257 stars

An overlay indicator that combines an ATR-based SuperTrend trailing stop with an integrated RSI-derived midline calculation on the price chart. The SuperTrend uses an ATR period and factor multiplier to plot dynamic green or red trend lines based on price dire

Indicator v5 TrendVolatility & bands
Updated 6 weeks ago · None stated GitHub repository of SuperTrend ATR + RSI
114 stars

ADX Strategy (original) is an overlay indicator that identifies trend-following trade signals using the Average Directional Index (ADX) combined with a Simple Moving Average filter. A long signal is generated when the ADX rises above a user-defined trend level

Indicator v4 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Strategy (original)

Moon Dev Lunar Sniper

by moondevonyt
92 stars

Moon Dev Lunar Sniper is a multi-indicator overlay that scores confluence across fast and slow EMAs, RSI, MACD, DMI, and BB width to fire signals only when score meets the minimum threshold. It plots buy and sell signals on the price chart, highlights cosmic b

Indicator v6 TrendOscillators & momentum Repaints
Updated 2 months ago · Custom licence GitHub repository of Moon Dev Lunar Sniper
56 stars

Double Screened Decision is a multi-timeframe trend and momentum indicator overlaid directly on the price chart. It dynamically selects a higher timeframe based on the active chart resolution to evaluate higher-timeframe MACD, Bollinger Bands, RSI, and Stochas

Indicator v5 TrendMoving averages Repaints
Updated 4 months ago · None stated GitHub repository of Double Screened Decision
55 stars

The VibeTrader Signal System is an overlay indicator that identifies trend direction and potential reversal conditions. It calculates a Supertrend line alongside Bollinger Bands and a 14-period RSI indicator. The script highlights bullish and bearish trends by

Indicator v6 TrendVolatility & bands
Updated 6 months ago · Apache-2.0 GitHub repository of VibeTrader Signal System

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers