Created
July 11, 2016 19:02
-
-
Save vhcandido/a171e79be3cd5c1198a64facf3b941b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(zoo) | |
| library(xts) | |
| library(chron) # xts index | |
| library(TTR) # TA indicators | |
| library(quantmod) # plotting | |
| # Path to the CSV file to be read | |
| file.path <- '../data/EURAUD.csv' | |
| # Dates subset to be used when plotting | |
| dates <- '2016-07::' | |
| fun <- function(d) as.chron(strptime(d, "%Y.%m.%d %H:%M")) | |
| prices <- as.xts(read.zoo(read.csv( | |
| file=file.path, | |
| header=F, | |
| col.names=c("GMT time", "Open","High","Low","Close","Volume")), | |
| FUN=fun)) | |
| # Cut the columns needed to plot the candlesticks | |
| # Select a subset to plot | |
| prices <- prices[dates,c('Open','High','Low','Close')] | |
| rsi <- RSI(prices$Close, n = 14) | |
| stoch_rsi <- stoch(rsi, nFastK = 8, nFastD = 5, nSlowD = 3) | |
| # Plot candlesticks | |
| chartSeries(prices) | |
| # quantmod function to plot built-in indicators | |
| #addRSI(14) | |
| # quantmod function to plot custom indicators | |
| addTA(stoch_rsi, col=c('blue','green','red')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment