N <- 1100
set.seed(1234)
mkt <- data.frame(EURUSD=1+0.01*cumsum(rnorm(N)), GBPCHF=1+0.01*cumsum(rnorm(N)))
#just random numbers... could you guess that by looking on charts?
plt.wid <- 250
plt.overlap <- 50
for (i in seq(from=0, to=nrow(mkt), by=plt.wid-plt.overlap)) {
idx.from <- max(c(i,1))
idx.to <- min(c(idx.from+plt.wid, nrow(mkt)))
idx <- idx.from:idx.to
png.file.name <- paste0("./plot_",formatC(idx.from, width = 5, format = "d", flag = "0"),"-",formatC(idx.to, width = 5, format = "d", flag = "0"),".png")
png(file=png.file.name, width = 1600, height = 900, units = "px", pointsize = 16)
old.par = par(mfcol=c(2,1), mar=c(2,4,1,2), bg="#555555")
plot.default(idx, ylab="EURUSD", as.vector(mkt$EURUSD[idx]), pch=19, col=topo.colors(24))
plot.default(idx, ylab="GBPCHF", as.vector(mkt$GBPCHF[idx]), pch=19, col=topo.colors(24))
par(old.par)
dev.off()
if (idx.to>=nrow(mkt)) break
}
#never mind plot.default() and as.vector(), it was written for working with xts
#the color is just to help synchronizing top and bottom series while viewing