Logical Sequence Operations in C#

Logical operators combine Boolean sequences element-by-element. They are typically used after comparison or pattern-matching operations.

In the C# API, analytics operate on Sequence values obtained from OrderedSequence<T> searches, direct ordered-sequence iteration, UnorderedSequence<T>.All, or positional projections such as quote.Close[dayRange].

For an overview see page The C# Sequence Class

Operations

left & right
Boolean AND.
left | right
Boolean OR.
left ^ right
Boolean exclusive OR.

Example

This example keeps only the days where both conditions are true: the price closed higher than it opened and the volume exceeded the chosen threshold.

    using (Sequence dayRange = quote.Day.Search(20130101u, SelectBoundary.Inclusive,
                                                20130401u, SelectBoundary.Inclusive))
    using (Sequence busyUpDays =
        (quote.Close[dayRange] > quote.Open[dayRange]) &
        (quote.Volume[dayRange] > Sequence.Constant(con, 1000u)))
    {
        PrintIntSequence(quote, dayRange.Filter(busyUpDays));
    }