simpSignal: Compute a buy/sell momentum signal based on the specifed look...

Description Usage Arguments Value Examples

View source: R/simpSignal.R

Description

This function will return a vector of buy/sell signals based on whether or not the current value of x is above or below the price of x. If the current price is above, the return entry is 1 otherwise the return entry will be zero. The return vector will be of length x - lookback. This function aids in building a smooth momentum signal by calling simpSignal() with many values of lookback and averaging the results.

Usage

1
simpSignal(x, lookback = 12)

Arguments

x

an xts object of prices.

lookback

the length of the look back period over which to evalute the momentum signal.

Value

an xts object of discrete momentum signals drawn from the set c(-1,1), where -1 indicates "short" or "sell" and 1 indicates "long" or "buy".

Examples

1
2
3
4
5
6
library(dMisc)
dts <- seq(Sys.Date()-99, Sys.Date(), 1)
returns <- matrix(rnorm(100),ncol = 1) / 100
ret.xts <- xts(returns, dts)
s <- simpSignal(ret.xts, lookback = 5)
plot(s, type = "l")

gtog/dMisc documentation built on May 17, 2019, 8:57 a.m.