def _cross_impl(values1, values2, start, end, signCheck):
    # Get both set of values.
    values1, values2 = _get_stripped(values1[start:end], values2[start:end], start > 0)

    # Compute differences and check sign changes.
    ret = 0
    diffs = compute_diff(values1, values2)
    diffs = filter(lambda x: x != 0, diffs)
    prevDiff = None
    for diff in diffs:
        if prevDiff is not None and not signCheck(prevDiff) and signCheck(diff):
            ret += 1
        prevDiff = diff
    return ret


# Note:
# Up to version 0.12 CrossAbove and CrossBelow were DataSeries.
# In version 0.13 SequenceDataSeries was refactored to support specifying a limit to the amount
# of values to hold. This was introduced mainly to reduce memory footprint.
# This change had a huge impact on the way DataSeries filters were implemented since they were
# mosly views and didn't hold any actual values. For example, a SMA(200) didn't hold any values at all
# but rather calculate those on demand by requesting 200 values from the DataSeries being wrapped.
# Now that the DataSeries being wrapped may not hold so many values, DataSeries filters were refactored
# to an event based model and they will calculate and hold resulting values as new values get added to
# the underlying DataSeries (the one being wrapped).
# Since it was too complicated to make CrossAbove and CrossBelow filters work with this new model (
# mainly because the underlying DataSeries may not get new values added at the same time, or one after
# another) I decided to turn those into functions, cross_above and cross_below.
dataset/ETHPy150Open gbeced/pyalgotrade/pyalgotrade/technical/cross.py/_cross_impl/original