def buy_signal(df):
    """Function calculates signal to open long position

    Args:
        df (pandas.DataFrame): pandas.DataFrame

    Returns:
        string: return "Buy" if condition is met else False
    """
    tsi = df["TSI"]
    tsi_ma = df["TSI_MA"]
    signal = ""

    if ((tsi[-2] < 0 and tsi_ma[-1] < 0) and (tsi[-1] > tsi_ma[-1] and tsi[-2] < tsi_ma[-2])) or (tsi[-1] > 0 and tsi[-2] < 0):
        signal = "Buy"
    else:
        signal = False

    return signal