@Mariano-Volpedo

Great strategy! Tried to replace with moving average and more on __init__ instead of next.
The results swift to 60-63 instead of ~55. Not sure is it because of any calculation error....

def __init__(self): self.l.m = bt.ind.MovAv.Simple(self.data.close, period=self.p.period) #replace with median self.l.nl=bt.And(self.data.close>self.l.m,self.data.close>self.data.close(-1)) self.l.nh=bt.And(self.data.close<self.l.m,self.data.close<self.data.close(-1)) self.l.upSum = bt.ind.SumN(self.l.nl, period=self.p.period) self.l.downSum = bt.ind.SumN(self.l.nh, period=self.p.period) self.l.mmi= 100.0 * (self.l.upSum+self.l.downSum)/(self.p.period - 1)