My weekly/month dema strategies doesn’t compatible with tradingview

Even after using GPT, I couldn’t quite figure out the exact reason why my code isn’t working as expected.

Here’s what I’m trying to achieve:

For Weekly Signals: My goal is to receive buy and sell signals immediately after the closing value of each Friday. I want these signals to be generated right after the market closes at the end of the week, so I can act on them without any delay.

For Monthly Signals: Similarly, I want to receive buy and sell signals right after the closing value of each month. These signals should be triggered immediately after the market closes on the last trading day of the month.

However, despite my efforts, the code doesn’t seem to be functioning correctly. Instead of getting the signals promptly after the weekly or monthly close, there appears to be a delay. I’m not sure why this is happening, and I haven’t been able to pinpoint the exact issue.

The aim is to have the signals reflect the most recent data as soon as it’s available, but the current implementation is falling short of that.

The code below is for monthly and weekly data

for stock in t2_list:

        # Download stock data for both intervals
        stock_data_weekly = download_weekly_data(stock, start_date, end_date)
        stock_data_weekly['Open'] = stock_data_weekly['Open'].round(2)
        stock_data_weekly['Close'] = stock_data_weekly['Close'].round(2)
        stock_data_weekly['High'] = stock_data_weekly['High'].round(2)
        stock_data_weekly['Low'] = stock_data_weekly['Low'].round(2)

        stock_data_monthly = download_monthly_data(stock, start_date, end_date)
        stock_data_monthly['Open'] = stock_data_monthly['Open'].round(2)
        stock_data_monthly['Close'] = stock_data_monthly['Close'].round(2)
        stock_data_monthly['High'] = stock_data_monthly['High'].round(2)
        stock_data_monthly['Low'] = stock_data_monthly['Low'].round(2)
        print(stock, len(stock_data_weekly), len(stock_data_monthly))
        sleep(2)
        if len(stock_data_weekly) >= 71:

            #stock_data_weekly = calculate_macd(stock_data_weekly)
            stock_data_weekly = calculate_macd_dema(stock_data_weekly)
            #print(stock_data_weekly.iloc[:, -8:])
            stock_data_weekly = check_crossovers(stock_data_weekly)

            # tradingview_data_weekly = format_tradingview_output(stock_data_weekly)

            for i, r in stock_data_weekly.iterrows():
                sent_date = i + timedelta(days = 6)
                date_str = sent_date.strftime('%Y-%m-%d')  # Adjust format as needed
                previous_friday = datetime.now() - timedelta(days = dates_diff[datetime.now().weekday()] + 1 )
                pre_previous_friday =previous_friday - timedelta(days = 7 )
                if r['Crossover'] != 'Neutral' and i>pre_previous_friday and i<previous_friday:
                    #pass
                    print('weekly', date_str, stock, r['Crossover'])
                    webhook_discord(webhook_url_weekly, date_str, r['Crossover'], stock, r['Crosspoint'])
                    sleep(5)

        if len(stock_data_monthly) >= 71:

            stock_data_monthly = calculate_macd_dema(stock_data_monthly)
            stock_data_monthly = check_crossovers(stock_data_monthly)

            for i , r in stock_data_monthly.iterrows():
                stock_month = i.month
                curr_month = datetime.now().month
                if curr_month == 1:
                    acc_month = 12
                else:
                    acc_month = curr_month-1
                sent_date = i + timedelta(days = 33)
                date_str = sent_date.strftime('%Y-%m')  # Adjust format as needed
                if r['Crossover'] != 'Neutral' and stock_month==acc_month:
                    print('monthly', date_str, stock, r['Crossover'])
                    webhook_discord(webhook_url_monthly, date_str, r['Crossover'], stock, r['Crosspoint'])
                    #pass
                    sleep(5)

if __name__ == "__main__":
    main()

I hired a python developer but he couldn’t figure it out also tried gpt but couldn’t find the proper solution.

The code below is for MAcd dema.

def calculate_macd_dema(df, short_window=12, long_window=26, signal_window=9):
    # Calculate Short-term DEMA
    def ema(series, span):
        ta_ema = ta.ema(series, span)
        return ta_ema

    def dema(series, span):
        ema1 = ema(series, span)
        ema2 = ema(ema1, span)
        return 2 * ema1 - ema2

    # Parameters
    sma = 12
    lma = 26
    tsp = 9

    # Calculate DEMAs
    df['DEMAfast'] = dema(df['Close'], sma)
    df['DEMAslow'] = dema(df['Close'], lma)


    # Calculate MACD Line and Signal Line

    df['MACD_DEMA'] = df['DEMAfast'] - df['DEMAslow']
    #print(df['MACD_DEMA'])
    df['Signal_Line'] = dema(df['MACD_DEMA'], tsp)

    df['MACDZeroLag'] = df['MACD_DEMA'] - df['Signal_Line']
    return df

# Check for MACD and Signal Line crossovers
def check_crossovers(df):
    # crossovers = []
    # for i in range(1, len(df)):

    #     if df['MACD_DEMA'].iloc[i] > df['Signal_Line'].iloc[i] and df['MACD_DEMA'].iloc[i - 1] <= df['Signal_Line'].iloc[i - 1]:
    #         crosspoint = df['Close'].iloc[i]
    #         crossovers.append((df.index[i], "Buy", crosspoint))

    #     elif df['MACD_DEMA'].iloc[i] < df['Signal_Line'].iloc[i] and df['MACD_DEMA'].iloc[i - 1] >= df['Signal_Line'].iloc[i - 1]:
    #         crosspoint = df['Close'].iloc[i]
    #         crossovers.append((df.index[i], "Sell", crosspoint))
    #     else:
    #         crossovers.append((df.index[i], "Neutral", None))  # None when there's no crosspoint
    df_macd_dema_1 = df['MACD_DEMA']
    df_macd_dema_2 = df['MACD_DEMA'].shift(1)

    df_signal_1 = df['Signal_Line']
    df_signal_2 = df['Signal_Line'].shift(1)

    df['Crossover'] = np.where((df_macd_dema_1 > df_signal_1) & (df_macd_dema_2 <= df_signal_2), 'Buy',
                           np.where((df_macd_dema_1 < df_signal_1) & (df_macd_dema_2 >= df_signal_2), 'Sell', 'Neutral'))

    df['Crosspoint'] = np.where( (df['Crossover']=='Buy') | (df['Crossover']=='Sell'), df['Close'], None)


    return df

Overall i guess the key point is in the upper section that i am missing.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

My weekly/month dema strategies doesn’t compatible with tradingview

Even after using GPT, I couldn’t quite figure out the exact reason why my code isn’t working as expected.

Here’s what I’m trying to achieve:

For Weekly Signals: My goal is to receive buy and sell signals immediately after the closing value of each Friday. I want these signals to be generated right after the market closes at the end of the week, so I can act on them without any delay.

For Monthly Signals: Similarly, I want to receive buy and sell signals right after the closing value of each month. These signals should be triggered immediately after the market closes on the last trading day of the month.

However, despite my efforts, the code doesn’t seem to be functioning correctly. Instead of getting the signals promptly after the weekly or monthly close, there appears to be a delay. I’m not sure why this is happening, and I haven’t been able to pinpoint the exact issue.

The aim is to have the signals reflect the most recent data as soon as it’s available, but the current implementation is falling short of that.

The code below is for monthly and weekly data

for stock in t2_list:

        # Download stock data for both intervals
        stock_data_weekly = download_weekly_data(stock, start_date, end_date)
        stock_data_weekly['Open'] = stock_data_weekly['Open'].round(2)
        stock_data_weekly['Close'] = stock_data_weekly['Close'].round(2)
        stock_data_weekly['High'] = stock_data_weekly['High'].round(2)
        stock_data_weekly['Low'] = stock_data_weekly['Low'].round(2)

        stock_data_monthly = download_monthly_data(stock, start_date, end_date)
        stock_data_monthly['Open'] = stock_data_monthly['Open'].round(2)
        stock_data_monthly['Close'] = stock_data_monthly['Close'].round(2)
        stock_data_monthly['High'] = stock_data_monthly['High'].round(2)
        stock_data_monthly['Low'] = stock_data_monthly['Low'].round(2)
        print(stock, len(stock_data_weekly), len(stock_data_monthly))
        sleep(2)
        if len(stock_data_weekly) >= 71:

            #stock_data_weekly = calculate_macd(stock_data_weekly)
            stock_data_weekly = calculate_macd_dema(stock_data_weekly)
            #print(stock_data_weekly.iloc[:, -8:])
            stock_data_weekly = check_crossovers(stock_data_weekly)

            # tradingview_data_weekly = format_tradingview_output(stock_data_weekly)

            for i, r in stock_data_weekly.iterrows():
                sent_date = i + timedelta(days = 6)
                date_str = sent_date.strftime('%Y-%m-%d')  # Adjust format as needed
                previous_friday = datetime.now() - timedelta(days = dates_diff[datetime.now().weekday()] + 1 )
                pre_previous_friday =previous_friday - timedelta(days = 7 )
                if r['Crossover'] != 'Neutral' and i>pre_previous_friday and i<previous_friday:
                    #pass
                    print('weekly', date_str, stock, r['Crossover'])
                    webhook_discord(webhook_url_weekly, date_str, r['Crossover'], stock, r['Crosspoint'])
                    sleep(5)

        if len(stock_data_monthly) >= 71:

            stock_data_monthly = calculate_macd_dema(stock_data_monthly)
            stock_data_monthly = check_crossovers(stock_data_monthly)

            for i , r in stock_data_monthly.iterrows():
                stock_month = i.month
                curr_month = datetime.now().month
                if curr_month == 1:
                    acc_month = 12
                else:
                    acc_month = curr_month-1
                sent_date = i + timedelta(days = 33)
                date_str = sent_date.strftime('%Y-%m')  # Adjust format as needed
                if r['Crossover'] != 'Neutral' and stock_month==acc_month:
                    print('monthly', date_str, stock, r['Crossover'])
                    webhook_discord(webhook_url_monthly, date_str, r['Crossover'], stock, r['Crosspoint'])
                    #pass
                    sleep(5)

if __name__ == "__main__":
    main()

I hired a python developer but he couldn’t figure it out also tried gpt but couldn’t find the proper solution.

The code below is for MAcd dema.

def calculate_macd_dema(df, short_window=12, long_window=26, signal_window=9):
    # Calculate Short-term DEMA
    def ema(series, span):
        ta_ema = ta.ema(series, span)
        return ta_ema

    def dema(series, span):
        ema1 = ema(series, span)
        ema2 = ema(ema1, span)
        return 2 * ema1 - ema2

    # Parameters
    sma = 12
    lma = 26
    tsp = 9

    # Calculate DEMAs
    df['DEMAfast'] = dema(df['Close'], sma)
    df['DEMAslow'] = dema(df['Close'], lma)


    # Calculate MACD Line and Signal Line

    df['MACD_DEMA'] = df['DEMAfast'] - df['DEMAslow']
    #print(df['MACD_DEMA'])
    df['Signal_Line'] = dema(df['MACD_DEMA'], tsp)

    df['MACDZeroLag'] = df['MACD_DEMA'] - df['Signal_Line']
    return df

# Check for MACD and Signal Line crossovers
def check_crossovers(df):
    # crossovers = []
    # for i in range(1, len(df)):

    #     if df['MACD_DEMA'].iloc[i] > df['Signal_Line'].iloc[i] and df['MACD_DEMA'].iloc[i - 1] <= df['Signal_Line'].iloc[i - 1]:
    #         crosspoint = df['Close'].iloc[i]
    #         crossovers.append((df.index[i], "Buy", crosspoint))

    #     elif df['MACD_DEMA'].iloc[i] < df['Signal_Line'].iloc[i] and df['MACD_DEMA'].iloc[i - 1] >= df['Signal_Line'].iloc[i - 1]:
    #         crosspoint = df['Close'].iloc[i]
    #         crossovers.append((df.index[i], "Sell", crosspoint))
    #     else:
    #         crossovers.append((df.index[i], "Neutral", None))  # None when there's no crosspoint
    df_macd_dema_1 = df['MACD_DEMA']
    df_macd_dema_2 = df['MACD_DEMA'].shift(1)

    df_signal_1 = df['Signal_Line']
    df_signal_2 = df['Signal_Line'].shift(1)

    df['Crossover'] = np.where((df_macd_dema_1 > df_signal_1) & (df_macd_dema_2 <= df_signal_2), 'Buy',
                           np.where((df_macd_dema_1 < df_signal_1) & (df_macd_dema_2 >= df_signal_2), 'Sell', 'Neutral'))

    df['Crosspoint'] = np.where( (df['Crossover']=='Buy') | (df['Crossover']=='Sell'), df['Close'], None)


    return df

Overall i guess the key point is in the upper section that i am missing.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

My weekly/month dema strategies doesn’t compatible with tradingview

Even after using GPT, I couldn’t quite figure out the exact reason why my code isn’t working as expected.

Here’s what I’m trying to achieve:

For Weekly Signals: My goal is to receive buy and sell signals immediately after the closing value of each Friday. I want these signals to be generated right after the market closes at the end of the week, so I can act on them without any delay.

For Monthly Signals: Similarly, I want to receive buy and sell signals right after the closing value of each month. These signals should be triggered immediately after the market closes on the last trading day of the month.

However, despite my efforts, the code doesn’t seem to be functioning correctly. Instead of getting the signals promptly after the weekly or monthly close, there appears to be a delay. I’m not sure why this is happening, and I haven’t been able to pinpoint the exact issue.

The aim is to have the signals reflect the most recent data as soon as it’s available, but the current implementation is falling short of that.

The code below is for monthly and weekly data

for stock in t2_list:

        # Download stock data for both intervals
        stock_data_weekly = download_weekly_data(stock, start_date, end_date)
        stock_data_weekly['Open'] = stock_data_weekly['Open'].round(2)
        stock_data_weekly['Close'] = stock_data_weekly['Close'].round(2)
        stock_data_weekly['High'] = stock_data_weekly['High'].round(2)
        stock_data_weekly['Low'] = stock_data_weekly['Low'].round(2)

        stock_data_monthly = download_monthly_data(stock, start_date, end_date)
        stock_data_monthly['Open'] = stock_data_monthly['Open'].round(2)
        stock_data_monthly['Close'] = stock_data_monthly['Close'].round(2)
        stock_data_monthly['High'] = stock_data_monthly['High'].round(2)
        stock_data_monthly['Low'] = stock_data_monthly['Low'].round(2)
        print(stock, len(stock_data_weekly), len(stock_data_monthly))
        sleep(2)
        if len(stock_data_weekly) >= 71:

            #stock_data_weekly = calculate_macd(stock_data_weekly)
            stock_data_weekly = calculate_macd_dema(stock_data_weekly)
            #print(stock_data_weekly.iloc[:, -8:])
            stock_data_weekly = check_crossovers(stock_data_weekly)

            # tradingview_data_weekly = format_tradingview_output(stock_data_weekly)

            for i, r in stock_data_weekly.iterrows():
                sent_date = i + timedelta(days = 6)
                date_str = sent_date.strftime('%Y-%m-%d')  # Adjust format as needed
                previous_friday = datetime.now() - timedelta(days = dates_diff[datetime.now().weekday()] + 1 )
                pre_previous_friday =previous_friday - timedelta(days = 7 )
                if r['Crossover'] != 'Neutral' and i>pre_previous_friday and i<previous_friday:
                    #pass
                    print('weekly', date_str, stock, r['Crossover'])
                    webhook_discord(webhook_url_weekly, date_str, r['Crossover'], stock, r['Crosspoint'])
                    sleep(5)

        if len(stock_data_monthly) >= 71:

            stock_data_monthly = calculate_macd_dema(stock_data_monthly)
            stock_data_monthly = check_crossovers(stock_data_monthly)

            for i , r in stock_data_monthly.iterrows():
                stock_month = i.month
                curr_month = datetime.now().month
                if curr_month == 1:
                    acc_month = 12
                else:
                    acc_month = curr_month-1
                sent_date = i + timedelta(days = 33)
                date_str = sent_date.strftime('%Y-%m')  # Adjust format as needed
                if r['Crossover'] != 'Neutral' and stock_month==acc_month:
                    print('monthly', date_str, stock, r['Crossover'])
                    webhook_discord(webhook_url_monthly, date_str, r['Crossover'], stock, r['Crosspoint'])
                    #pass
                    sleep(5)

if __name__ == "__main__":
    main()

I hired a python developer but he couldn’t figure it out also tried gpt but couldn’t find the proper solution.

The code below is for MAcd dema.

def calculate_macd_dema(df, short_window=12, long_window=26, signal_window=9):
    # Calculate Short-term DEMA
    def ema(series, span):
        ta_ema = ta.ema(series, span)
        return ta_ema

    def dema(series, span):
        ema1 = ema(series, span)
        ema2 = ema(ema1, span)
        return 2 * ema1 - ema2

    # Parameters
    sma = 12
    lma = 26
    tsp = 9

    # Calculate DEMAs
    df['DEMAfast'] = dema(df['Close'], sma)
    df['DEMAslow'] = dema(df['Close'], lma)


    # Calculate MACD Line and Signal Line

    df['MACD_DEMA'] = df['DEMAfast'] - df['DEMAslow']
    #print(df['MACD_DEMA'])
    df['Signal_Line'] = dema(df['MACD_DEMA'], tsp)

    df['MACDZeroLag'] = df['MACD_DEMA'] - df['Signal_Line']
    return df

# Check for MACD and Signal Line crossovers
def check_crossovers(df):
    # crossovers = []
    # for i in range(1, len(df)):

    #     if df['MACD_DEMA'].iloc[i] > df['Signal_Line'].iloc[i] and df['MACD_DEMA'].iloc[i - 1] <= df['Signal_Line'].iloc[i - 1]:
    #         crosspoint = df['Close'].iloc[i]
    #         crossovers.append((df.index[i], "Buy", crosspoint))

    #     elif df['MACD_DEMA'].iloc[i] < df['Signal_Line'].iloc[i] and df['MACD_DEMA'].iloc[i - 1] >= df['Signal_Line'].iloc[i - 1]:
    #         crosspoint = df['Close'].iloc[i]
    #         crossovers.append((df.index[i], "Sell", crosspoint))
    #     else:
    #         crossovers.append((df.index[i], "Neutral", None))  # None when there's no crosspoint
    df_macd_dema_1 = df['MACD_DEMA']
    df_macd_dema_2 = df['MACD_DEMA'].shift(1)

    df_signal_1 = df['Signal_Line']
    df_signal_2 = df['Signal_Line'].shift(1)

    df['Crossover'] = np.where((df_macd_dema_1 > df_signal_1) & (df_macd_dema_2 <= df_signal_2), 'Buy',
                           np.where((df_macd_dema_1 < df_signal_1) & (df_macd_dema_2 >= df_signal_2), 'Sell', 'Neutral'))

    df['Crosspoint'] = np.where( (df['Crossover']=='Buy') | (df['Crossover']=='Sell'), df['Close'], None)


    return df

Overall i guess the key point is in the upper section that i am missing.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật