[R] Custom Indicator Quantstrat Problem

P95 F95 f@bbropietro @ending from y@hoo@it
Sat Jul 14 11:40:57 CEST 2018


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 - 

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 

Thank you,

Best regards,

Pietro Fabbro
	[[alternative HTML version deleted]]

More information about the R-help mailing list