Volatility Index

Smaller investors have been attempting to measure and follow large market players and institutions in the equity markets for more than 100 years. It is important to remember that these large market movers are like ocean liners - they need plenty of time and water to change direction. If institutions think the market is turning bearish, they can’t quickly unload the stock; instead, they buy put option contracts and/or sell call option contracts to offset some of the expected losses. VIX is used as a contrary market indicator. The Chicago Board of Options Exchange (CBOE) creates and tracks an index know as the Volatility Index (VIX), which is based on the implied volatility of S&P 500 Index options. Monitoring the VIX isn’t so much about institutions buying and selling shares but whether institutions are attempting to hedge their portfolios. If institutions are bearish, they will likely purchase puts as a form of portfolio insurance. The VIX rises as a result of increased demand for puts but also swells because the put options’ demand increase will cause the implied volatility to rise.

Market Bearish => VIX rises

“When the VIX is high, it’s time to buy. When the VIX is low, look out below!” When the VIX reaches the resistance level, it is considered high and is a signal to purchase stocks - particularly those that reflect the S&P 500. Support bounces indicate market tops and warn of a potential downturn in the S&P 500.

Collect and compare S&P 500 and VIX data

The Relationship of the SP500 and the VIX® Index The chart below shows the daily closing prices for the S&P 500 and VIX during the first quarter of 2018. The blue line and left scale represent the S&P 500 while the red line and right scale represent VIX. This chart is a typical example of how the S&P 500 and VIX move relative to each other on a daily basis.

require('xts')
## Loading required package: xts
## Warning: package 'xts' was built under R version 3.4.3
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 3.4.3
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
require('quantmod')
## Loading required package: quantmod
## Warning: package 'quantmod' was built under R version 3.4.3
## Loading required package: TTR
## Warning: package 'TTR' was built under R version 3.4.3
## Version 0.4-0 included new data defaults. See ?getSymbols.
# S&P 500 vs VIX
getSymbols(c("^GSPC","^VIX"),from = as.Date("2017-11-04"), to = as.Date("2018-04-04"))
## 'getSymbols' currently uses auto.assign=TRUE by default, but will
## use auto.assign=FALSE in 0.5-0. You will still be able to use
## 'loadSymbols' to automatically load data. getOption("getSymbols.env")
## and getOption("getSymbols.auto.assign") will still be checked for
## alternate defaults.
## 
## This message is shown once per session and may be disabled by setting 
## options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.
## 
## WARNING: There have been significant changes to Yahoo Finance data.
## Please see the Warning section of '?getSymbols.yahoo' for details.
## 
## This message is shown once per session and may be disabled by setting
## options("getSymbols.yahoo.warning"=FALSE).
## [1] "GSPC" "VIX"
df = as.data.frame(merge(GSPC,VIX))
df <- data.frame(date = row.names(df), df, row.names = NULL)

plot (df$date,df$GSPC.Adjusted)
lines(df$date,df$GSPC.Adjusted,col="blue")
par(new = TRUE)
plot (df$date,df$VIX.Adjusted,type = "l", axes = FALSE, bty = "n", xlab = "", ylab = "")
lines(df$date,df$VIX.Adjusted,col="red")
axis(side=4, at = pretty(range(df$VIX.Adjusted)))
abline(h=20,col = "gray60")
abline(h=30,col = "green")

## [1] "GSPC" "VIX"

Check the trend for SPY

getSymbols("SPY", from="2016-04-03", to="2018-04-03")
## [1] "SPY"
chartSeries(SPY, TA="addLines(h=c(255,285))", theme="white")

Check the Privot points

getSymbols("SPY", from="2018-01-03", to="2018-04-03")
## [1] "SPY"
# First Six Lines of Data
head(SPY) 
##            SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
## 2018-01-03   268.96   270.64  268.96    270.47   90070400     269.3911
## 2018-01-04   271.20   272.16  270.54    271.61   80636400     270.5265
## 2018-01-05   272.51   273.56  271.95    273.42   83524000     272.3293
## 2018-01-08   273.31   274.10  272.98    273.92   57319200     272.8273
## 2018-01-09   274.40   275.25  274.08    274.54   57254000     273.4449
## 2018-01-10   273.68   274.42  272.92    274.12   69574300     273.0265
# Candlestick Chart of SPY
chartSeries(SPY) 

# Average of High,Low & Close Price (H+L+C/3)
center <- xts(rowSums(HLC(SPY))/3,order.by=index(SPY)) 

# First Six Lines of Data
head(center) 
##                [,1]
## 2018-01-03 270.0233
## 2018-01-04 271.4367
## 2018-01-05 272.9767
## 2018-01-08 273.6667
## 2018-01-09 274.6233
## 2018-01-10 273.8200
# First Resistance (R1) = (2*P) - Low
R1 <- (2*center)-Lo(SPY) 

# First Support (S1) = (2*P) - High
S1 <- (2*center)-Hi(SPY) 

# Second Resistance (R2) = P + (R1-S1)
R2 <- center + (R1 - S1) 

# Second Support (S2) = P - (R1- S1)
S2 <- center - (R1 - S1) 

# Combining all Calculations in adjacent columns
ret <- cbind(center,R1,R2,S1,S2) 

# Column Names
colnames(ret) <- c('center','R1','R2','S1','S2') 

# Combining both the sheets or files
dat = cbind(SPY,ret) 

# First Six Lines of Data
head(dat) 
##            SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
## 2018-01-03   268.96   270.64  268.96    270.47   90070400     269.3911
## 2018-01-04   271.20   272.16  270.54    271.61   80636400     270.5265
## 2018-01-05   272.51   273.56  271.95    273.42   83524000     272.3293
## 2018-01-08   273.31   274.10  272.98    273.92   57319200     272.8273
## 2018-01-09   274.40   275.25  274.08    274.54   57254000     273.4449
## 2018-01-10   273.68   274.42  272.92    274.12   69574300     273.0265
##              center       R1       R2       S1       S2
## 2018-01-03 270.0233 271.0867 271.7034 269.4067 268.3433
## 2018-01-04 271.4367 272.3333 273.0567 270.7133 269.8167
## 2018-01-05 272.9767 274.0033 274.5867 272.3934 271.3667
## 2018-01-08 273.6667 274.3533 274.7867 273.2333 272.5467
## 2018-01-09 274.6233 275.1667 275.7933 273.9967 273.4533
## 2018-01-10 273.8200 274.7200 275.3200 273.2200 272.3200
df = as.data.frame(dat)
df <- data.frame(date = row.names(df), df, row.names = NULL)

plot(df$date,df$center,ylim=c(245,295), title='Support and Resistance')
lines(df$date,df$center)
lines(df$date,df$R1,col='blue')
lines(df$date,df$S1,col='blue')
lines(df$date,df$R2,col='red')
lines(df$date,df$S2,col='red')

# Saving a copy as CSV file
write.csv(dat,"Datasupres.csv") 

Check the trend for SPY

# Candlestick Chart of SPY
chartSeries(SPY) 

# Adding Support1 Line to Candlestick Chart
addTA(dat$S1, on=1, col='lightblue') 

# Adding Support2 Line to Candlestick Chart
addTA(dat$S2, on=1, col='blue') 

# Adding Resistance1 Line to Candlestick Chart
addTA(dat$R1, on=1, col='pink') 

# Adding Resistance2 Line to Candlestick Chart
addTA(dat$R2, on=1, col='red') 

A Low VIX Signals More Stock-Market Gains

If history is a reliable guide, the sudden and sharp decline in the CBOE Volatility Index-or VIX-suggests a few more weeks of stock-market strength.

The VIX, which is calculated from options prices, is also called the “fear index” for its propensity to spike higher when the market runs into trouble. When investors feel the need to hedge, its value goes up. And when investors feel more confident, the going price of hedging options falls, and so does the VIX.

S&P 500 Index

getSymbols(c("^GSPC","^VIX"),from = as.Date("2017-11-04"), to = as.Date("2018-04-04"))
## [1] "GSPC" "VIX"
df = as.data.frame(merge(GSPC,VIX))
df <- data.frame(date = row.names(df), df, row.names = NULL)

plot(df$date,df$GSPC.Adjusted)
lines(df$date,df$GSPC.Adjusted)

Daily change of VIX

plot(df$date,Delt(df$VIX.Adjusted))
lines(df$date,Delt(df$VIX.Adjusted))
abline(h=0)
abline(h=0.2,col="red")
abline(h=-0.2,col="green")

VIX daily change vs S&P 500 Index

plot (df$date,df$GSPC.Adjusted)
lines(df$date,df$GSPC.Adjusted,col="blue")
par(new = TRUE)
plot (df$date,Delt(df$VIX.Adjusted),type = "l", axes = FALSE, bty = "n", xlab = "", ylab = "")
lines(df$date,Delt(df$VIX.Adjusted),col="black")
abline(h=0)
abline(h=0.2,col="red")
abline(h=-0.2,col="green")