def index_next_crossing(value, array, starting_index=0, direction=1):
    """
    starts at starting_index, and walks through the array until
    it finds a crossing point with value

    set direction=-1 for down crossing
    """
    for n in range(starting_index, len(array) - 1):
        if (value - array[n]) * direction >= 0 and (value - array[n + 1]
            ) * direction < 0:
            return n
    return -1
