# NOT RUN {
library(quantmod)
getSymbols("SPY", from = "2016-12-01", auto.assign=TRUE)
difference <- SPY[, "SPY.Open"] - SPY[, "SPY.Close"]
decreasing <- which(difference < 0)
increasing <- which(difference > 0)
dyData <- SPY[, "SPY.Close"]
ribbonData <- rep(0, nrow(dyData))
ribbonData[decreasing] <- 0.5
ribbonData[increasing] <- 1
dygraph(dyData) %>%
dyRibbon(data = ribbonData, top = 0.1, bottom = 0.02)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab