classMFI(bt.Indicator):lines=('mfi',)params=dict(period=14)alias=('MoneyFlowIndicator',)def__init__(self):tprice=(self.data.close+self.data.low+self.data.high)/3.0mfraw=tprice*self.data.volumeflowpos=bt.ind.SumN(mfraw*(tprice>tprice(-1)),period=self.p.period)flowneg=bt.ind.SumN(mfraw*(tprice<tprice(-1)),period=self.p.period)mfiratio=bt.ind.DivByZero(flowpos,flowneg,zero=100.0)self.l.mfi=100.0-100.0/(1.0+mfiratio)