Crossover Detection
All functions · nseries package
CrossesAbove
func (s Series) CrossesAbove(val any) bool
CrossesAbove returns a boolean to indicate whether the second-last series value was less than or equal to the provided value/series and the last series value is greater than the provided value/value.
CrossesAboveS
func (s Series) CrossesAboveS(val any) Series
CrossesAboveS returns a series to indicate whether the prior series value was less than or equal to the provided value/series and the current series value is greater than the provided value/series. The series returned will contain 1.0 where the test is true and 0.0 where it is false, and always has the receiver’s length. The value may be any built-in or defined real numeric scalar type, or another Series; any other type, including a plain []float64, gives all zeros, as does a receiver of fewer than two bars. A Series value is right-aligned with the receiver at the most recent bar and compared over the bars they share. A cross also needs its prior bar inside that overlap, so the first shared bar and every position before it are 0.0, and an overlap of fewer than two bars gives all zeros. When both series have at least two bars, the value at the most recent bar agrees with CrossesAbove. Series are paired by position only; see “Time alignment” in the manual.
CrossesBelow
func (s Series) CrossesBelow(val any) bool
CrossesBelow returns a boolean to indicate whether the second-last series value was greater than or equal to the provided value/series and the last series value is less than the provided value/series.
CrossesBelowS
func (s Series) CrossesBelowS(val any) Series
CrossesBelowS returns a series to indicate whether the prior series value was greater than or equal to the provided value/series and the current series value is less than the provided value/series. The series returned will contain 1.0 where the test is true and 0.0 where it is false, and always has the receiver’s length. The value may be any built-in or defined real numeric scalar type, or another Series; any other type, including a plain []float64, gives all zeros, as does a receiver of fewer than two bars. A Series value is right-aligned with the receiver at the most recent bar and compared over the bars they share. A cross also needs its prior bar inside that overlap, so the first shared bar and every position before it are 0.0, and an overlap of fewer than two bars gives all zeros. When both series have at least two bars, the value at the most recent bar agrees with CrossesBelow. Series are paired by position only; see “Time alignment” in the manual.