Dear community,

I am trying to build a On-Balance Volume (OBV) indicator that I can use in the CoarseFiltterFunction as a filter to select stocks.

Anyone got suggestions on how to build this On-Balance Volume (OBV) indicator.

class CoarseUniverseAlgorithm(QCAlgorithm):
    def Initialize(self):
        self.AddUniverse(self.CoarseFilterFunction)

    def CoarseFilterFunction(self, coarse):
         ...

class SelectionData():
    def __init__(self):
        self.obv = OnBalanceVolume()

    def is_ready(self):
        return self.obv.IsReady
    
    def update(self, history):
        for bar in history.itertuples():
            tradeBar = TradeBar(bar.Index[1], bar.Index[0], bar.open, bar.high, bar.low, bar.close, bar.volume)
            self.obv.Update(tradeBar)

The python code gives an Error as shown below.

169422_1646500589.jpg