[Python] Cannot Apply + Operator Between Series[float] and float

Discussão em 'Python' iniciado por Stack, Abril 24, 2025.

  1. Stack

    Stack Membro Participativo

    I'm developing an indicator in Indie. I’m trying to calculate Bollinger Bands and Keltner Channels, but I’m running into an error when adding a Series[float] to a float value.

    Here’s the error message:


    Error: 20:20 cannot apply operator + to operands of types: <class 'indie.Series[float]'> and <class 'float'>
    ​

    Here’s the relevant code snippet:

    sDev = StdDev.new(self.close, length)
    mid_line_bb = Sma.new(self.close, length)
    lower_band_bb = mid_line_bb + num_dev_dn * sDev[0] # <-- ERROR HERE
    upper_band_bb = mid_line_bb + num_dev_up * sDev[0] # <-- ERROR HERE


    What I’ve Tried:

    1. Wrapping sDev[0] with MutSeriesF.new(), but that caused another issue.
    2. Using sDev.value_or(0) (which doesn’t seem to exist in Indie v4).
    3. Looking for an explicit type conversion function in Indie’s documentation.

    I assume the issue is that mid_line_bb is a Series[float], while sDev[0] is a single float. How should I properly handle this type of mismatch in Indie?

    Continue reading...

Compartilhe esta Página