@run-out It worked! I had tried running the next() within the indicator class but I wasn't including the subscript [0] in median[0].
THANKS A LOT!
For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

Best posts made by carlrom
-
RE: Median calculation
Latest posts made by carlrom
-
RE: Median calculation
@run-out It worked! I had tried running the next() within the indicator class but I wasn't including the subscript [0] in median[0].
THANKS A LOT! -
Median calculation
Hello,
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.
Many thanks.