breakoutSignal: Compute a 'breakout' momentum signal over the specified...

Description Usage Arguments Value Examples

View source: R/breakoutSignal.R

Description

This function will return a vector of buy/sell signals based on whether or not the current value of x is above the maximum or below the minimum price of x over the lookback period. If the current price is above the maximum, the return value is 1. If the current price is below the minumum, then the return value is -1. Otherwise, the return entry will be the previous signal. 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
breakoutSignal(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 <- breakoutSignal(ret.xts, lookback = 5)
plot(s, type = "l")

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