0
votes

I have a ChartSeries error in my production code. Code Below

chartSeries(Stock, theme = chartTheme("white"), TA=c(addTA(ATR(Stock[,c("High","Low","Close")], n=14)), addTA(ADX(Stock[,c("High","Low","Close")])), addTA(OBV(Stock[,"Close"], Stock[,"Total.Trade.Quantity"])), addTA(chaikinAD(Stock[,c("High","Low","Close")], Stock[,"Total.Trade.Quantity"])), addTA(CMF(Stock[,c("High","Low","Close")], Stock[,"Total.Trade.Quantity"])), addRSI(), addSMI(), addMACD(type = "DEMA"), addBBands(), addDEMA(n = 20, on = 1, with.col = Cl, overlay = TRUE, col = "blue")), subset='last 4 months')

Error Code:

Error in seq.default(min(tav * 0.975, na.rm = TRUE), max(tav * 1.05, na.rm = TRUE), : 'from' must be a finite number In addition: Warning messages: 1: In min(tav * 0.975, na.rm = TRUE) : no non-missing arguments to min; returning Inf 2: In max(tav * 1.05, na.rm = TRUE) : no non-missing arguments to max; returning -Inf

Data file info:

So my data file, an xts styled OHLCV (csv), has 1 row of a total of 4718 rows with 3 NA values (on the first row of the file). The rest of the rows are completely filled with no other NA values.

Edit:

Just omitted the row containing NA values, and still get the same error. So the error has to do something with something else.

Edit 2:

So I found that the error is localized to the addTA(OBV(Stock[,"Close"], Stock[,"Total.Trade.Quantity"])) function/arguments. Any suggestions or tips?

1
thanks @Konrad for the edit in the format, I'm new to posting questions here, so any help is much appreciated!M PM
Regarding your OBV error message this gives me no errors: getSymbols("IBM"); chartSeries(IBM, theme = chartTheme("white"), TA = "addOBV()")G. Grothendieck
@G.Grothendieck Thanks for the suggestion, but addOBV() does not work for me, because my Quandl data contains the column Total.Trade.Quantity instead of Volume, therefore the addOBV() does not recognize the column. Therefore, I used the addTA(OBV()) function to assign the column containing the volume data. It works for a few of the symbols I have, and for the remaining symbols it provides me the error I posted on top.M PM
Could you please provide a sample of your data so that we can reproduce the error?Vincent K
This google drive link, contains the stock.csv file (drive.google.com/drive/folders/…). So if you read the file into R, and then run my above code with the necessary libraries, I believe you should be able to reproduce the error I get. Additional info, I read the file into R using Zoo, and then I coerce the file into an xts object using xts(), and then I run my above chartSeries().M PM

1 Answers

1
votes

This code resolves your problem:

Stock <- AAPL["2018-08"]
chartSeries(Stock, theme="white")
addTA(OBV(Cl(Stock), Vo(Stock)))

Stock prices chart with OBV added