Mario Portilho
Mario Portilho

Reputation: 11

ValueError: Operands are not aligned. Do `left, right = left.align(right, axis=1, copy=False)` before operating

I do I get this error: "ValueError: Operands are not aligned. Do left, right = left.align(right, axis=1, copy=False) before operating.", I have no clue, if you know please help me

    # MACD Parameters
    macd_f = 12
    macd_s = 26
    macd_s_p = 9
    
    # Ensure 'Close' is a 1D array
    close_prices = data['Close'].values.flatten()  # Convert to numpy array
    
    # Calculate MACD and Signal Line using TA-Lib
    macd, macd_signal, _ = talib.MACD(close_prices, fastperiod=macd_f, slowperiod=macd_s, signalperiod=macd_s_p)
    
    # VWAP Calculation
    data['VWAP'] = (data['Volume'] * (data['High'] + data['Low'] + data['Close']) / 3).cumsum() / data['Volume'].cumsum()
    
    data['Buy_Signal'] = np.where((data['MACD'] > data['MACD_Signal']) & (data['Close'] > data['VWAP']), 1, 0)```



Upvotes: 0

Views: 423

Answers (0)

Related Questions