intersection {atmi}R Documentation

intersection points

Description

Identifies intersection points of two sequences or a sequence and a horizontal line.

Usage

intersection(sequenceInd = NA, sequenceSig = NA, hLine = NA, plot = TRUE)

Arguments

sequenceInd the first sequence (the first sequence (a data vector).).
sequenceSig the second sequence (a data vector).
hLine the horizontal line (a number).
plot logical; if TRUE, the intersection will be plotted.

Details

The used sequences can contain NAs only at the beginning. The function was written for the analysis of technical indicators, which are based on closing prices. Therefore an intersection point can only be identified, when the intersection has already happened. For example if an intersection occurred between day 5 and 6, the 6th day is an intersection day (see example 1).

Value

upIntersection vector of indices, where the sequenceInd crossed the sequenceSig or the hLine from below.
downIntersection vector of indices, where the sequenceInd crossed the sequenceSig or the hLine from above.
numEqualUp number of points, where an UpIntersection happened and on the day before the sequenceInd was exactly equal to sequenceSig or the hLine.
numEqualDown number of points, where an DownIntersection happened and on the day before the sequenceInd was exactly equal to sequenceSig or the hLine (see example 3).

Author(s)

Waldemar Kemler, Peter Schaffner

Examples

# Example 1: sequenceInd crosses sequenceSig from below upwards between day 5 and 6.
intersection(sequenceInd=c(1:10),sequenceSig=c(10:1),plot=TRUE)
# Example 2: sequenceInd crosses a hLine.
intersection(sequenceInd=c(1:10),hLine=5,plot=TRUE)
# Example 3: sequenceInd crosses sequenceSig from above and on the day before the sequenceInd is exactly equal to sequenceSig. Furthermore sequenceInd contains NAs at the beginning.
intersection(sequenceInd=c(NA,NA,7:1), sequenceSig=c(1:10),plot=TRUE)
# Example 4:
intersection(sequenceInd=c(1,2,4,4,4,7,6,6,5), sequenceSig=c(6,5,4,4,4,4,3,2,2),plot=TRUE)

[Package atmi version 1.0 Index]