[R] Custom Indicator Quantstrat Problem

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sat Jul 14 14:18:18 CEST 2018


This mailing list is plain text only (read the Posting Guide). When you send HTML-formatted email, what we see is often not what you saw. The solution is for you to figure out how to send your email in plain text format to begin with. Since the syntax in your code below is not valid, I am guessing your message has been corrupted by posting HTML format.

Also, at least half the time your troubles start with the data you have, so it is important to supply enough example data to let the us run your code ourselves and trigger any problem you are having. See any or all of [1][2][3] for advice on how to create a reproducible example.

[1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example

[2] http://adv-r.had.co.nz/Reproducibility.html

[3] https://cran.r-project.org/web/packages/reprex/index.html (read the vignette)


On July 14, 2018 2:40:57 AM PDT, P95 F95 via R-help <r-help using r-project.org> wrote:
>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 using 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.

-- 
Sent from my phone. Please excuse my brevity.




More information about the R-help mailing list