Quite often on twitter I hear many people mention NYSE Advance & Decline figures. Advances and declines refers to the number of stocks that closed at a higher and lower price than the previous day, respectively.
When looking at new indicators I prefer to look at the raw data, over glancing though lots of charts. In the past I used some quite expensive proprietary software which seemed to give very accurate signals based off the McClellan Oscillator, however not being able to look at the raw data put me off and I swiftly cancelled my subscription. Instead I decided to try and find free sources of NYSE Adv Dec figures and code my own indicators. After some googling I found the site unicorn.us.com who keep a database of Adv Dec figures here, spanning all the way back to 1969. Using R we can download the data directly into R using the data.table package. Heres how its done;
library(data.table) library(lubridate) advn <- "http://unicorn.us.com/advdec/NYSE_advn.csv" decln <- "http://unicorn.us.com/advdec/NYSE_decln.csv" dat <- fread(advn) dat$V1 <- ymd(dat$V1) dat <- cbind(dat, fread(decln, select = 2)) names(dat) <- c("Date", "Advn", "Decln")
The code above first loads the libraries “data.table” and “lubridate”, the two urls for Adv Dec data are stored as variables “advn’ & “decln”, then the data is downloaded using the data.table::fread function.
The date is converted from a string to date format using lubridate::ymd function and the data is all stored in an object called dat. We then give the columns there respective names. NYSE Breadth (adv – dec) can then be created using;
dat$Breadth <- dat$Advn - dat$Decln
A quick summary of the breadth data gives us the following;
> summary(dat$Breadth) Min. 1st Qu. Median Mean 3rd Qu. Max. -3197.00 -372.50 48.00 29.27 429.00 2871.00