@run-out It worked! I had tried running the next() within the indicator class but I wasn't including the subscript  in median.
THANKS A LOT!
Best posts made by carlrom
Latest posts made by carlrom
I am new to backtrader and until today had managed to find all the answers in the Community. I can't find help on how to calculate the median (P50) of a line for the last 'period' bars (so basically a movav but for the median not the mean). I am creating an indicator and have managed to implement the calculation (sorting and retrieving the value in the middle) within next() but for efficiency and plotting I would like to have a class for the indicator and the calculation in init.