Learn R Programming

PMwR (version 0.11-0)

streaks: Up and Down Streaks

Description

Compute up and down streaks for time-series.

Usage

streaks(x, ...)

# S3 method for default streaks(x, up = 0.2, down = -0.2, initial.state = NA, …) # S3 method for zoo streaks(x, up = 0.2, down = -0.2, initial.state = NA, …) # S3 method for NAVseries streaks(x, up = 0.2, down = -0.2, initial.state = NA, …)

Arguments

x

a price series

initial.state

NA, "up" or "down"

up

a number, such as 0.1 (i.e. 10%)

down

a negative number, such as -0.1 (i.e. -10%)

other arguments passed to methods

Value

A data.frame:

start

beginning of streak

end

end of streak

state

up, down or NA.

Details

streaks is a generic function. It computes series of uninterrupted up and down movements in a price series. Uninterrupted is meant in the sense that no countermovement of down (up) percent or more occurs in up (down) movements.

There are methods for numeric vectors, and NAVseries and zoo objects.

See Also

drawdowns

Examples

Run this code
# NOT RUN {
library("PMwR")
library("zoo")
dax <- zoo(DAX[[1]], as.Date(row.names(DAX)))
streaks(dax)
# }

Run the code above in your browser using DataLab