Tag Archives: percentage

R source code for Oil CL Spread Percentage Change Chart

R source code for Oil CL Spread Percentage Change Chart

This generous contribution came from the NYC Conatact so thanks him big time! Chart is at end

 

R packages I use: utils, stats, methods, graphics, grDevices, datasets

R code for the new chart

CL1 = read.csv(‘http://www.quandl.com/api/v1/datasets/CHRIS/CME_CL1.csv?&auth_token=EFqKm1HWP2FJZNzJywN9&trim_start=1983-03-31&trim_end=2014-04-03&sort_order=desc’, colClasses=c(‘Date’=’Date’))

CL2 = read.csv(‘http://www.quandl.com/api/v1/datasets/CHRIS/CME_CL2.csv?&auth_token=EFqKm1HWP2FJZNzJywN9&trim_start=1983-03-30&trim_end=2014-04-03&sort_order=desc’, colClasses=c(‘Date’=’Date’))
CL_Spread <- CL1[“Date”]

CL_Spread[“Settle”] = CL1[“Settle”] – CL2[“Settle”]

N <- nrow(CL_Spread)
for (i in 1:N)
CL_Spread[i, “PrecentChange”] = round(((CL_Spread[i,”Settle”] – CL_Spread[i+1,”Settle”])/CL_Spread[i+1,”Settle”])*100,digits=2)

rdate <- as.Date(CL_Spread$Date,”%yy-%m-%d”)
fix(rdate)
plot(CL_Spread$PrecentChange~rdate, type=”l”,col=”blue”,axes=F)
box()
axis(1,rdate,format(rdate,”%m-%y”))
axis(2,CL_Spread$PrecentChange)

Join my FREE newsletter to see what other contributions come my way 

CL Spread Percentage Change Chart

 

NOTE I now post my TRADING ALERTS into my personal FACEBOOK ACCOUNT and TWITTER. Don't worry as I don't post stupid cat videos or what I eat!