Hello all!
I'm trying to implement a simple DMI strategy where:
buy when ADX > 25 & DIPlus > DIMinus
sell when ADX > 25 & DI Plus < DIMinus
Here is the strategy:
class DMI(bt.Strategy):
def __init__(self):
self.dmi = bt.ind.DirectionalMovementIndex()
def next(self):
if not self.position:
if self.dmi.adx[0] > 25 and (self.dmi.DIplus[0] > self.dmi.DIminus[0]):
self.buy()
else:
if self.dmi.adx[0] > 25 and (self.dmi.DIplus[0] < self.dmi.DIminus[0]):
self.close()
The strategy runs but gives an incorrect result as it buys once and never sells.
Someone has an idea of what's going on?
Thanks