Hi. I am new in the forum and in R, I would like to ask for help. I am trying to add a custom indicator in quantstrat for my trading strategy but something does not work.
When I insert the command: #out <- applyStrategy(strategy=strategy.st <http://strategy.st/>,portfolios=portfolio.st <http://portfolio.st/>) I get: #Error in .xts(e, .index(e1), .indexCLASS = indexClass(e1), .indexFORMAT = #indexFormat(e1), : #index length must match number of observations #Inoltre: Warning messages: #1: In match.names(column, colnames(data)) : #all columns not located in CNOwma for RUT.Open RUT.High RUT.Low RUT.Close #RUT.Volume RUT.Adjusted X1.Channel.Normalization.Operator.smoothed.by.a.LWMA #2: In min(j, na.rm = TRUE) : #no non-missing arguments to min; returning Inf #3: In max(j, na.rm = TRUE) : #no non-missing arguments to max; returning -Inf The coding of the indicator is: #wma <- WMA(Cl(mktdata), 4, wts=c(1:4)) #wmamaxt <- rollmaxr(wma, 30, fill = NA) #wmamint <- - rollmaxr(- wma, 30, fill = NA) #CNOwma <- function (mktdata=quote(mktdata),x) {(wma - wmamint) / (wmamaxt - #wmamint)} The add.indicator function is: #add.indicator(strategy = strategy.st <http://strategy.st/>, #name = 'CNOwma', #arguments = list(quote(Cl(mktdata)[,1]), n=4), #label = 'Channel Normalization Operator smoothed by a LWMA') The first 32 elements of CNOwma(mktdata) are NA. Could this explain the problem? Thank you, Best regards, Pietro Fabbro [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.