def MIDPOINT(df, n, price='Close'):
    """
    MidPoint over period
    source: http://www.tadoc.org/indicator/MIDPOINT.htm
    """
    midpoint_list = []
    i = 0
    while i < len(df[price]):
        if i + 1 < n:
            midpoint = float('NaN')
        else:
            start = i + 1 - n
            end = i + 1
            midpoint = (max(df[price][start:end]) + min(df[price][start:end])
                ) / 2
        midpoint_list.append(midpoint)
        i += 1
    return midpoint_list
