Simple DMI strategy gives only buy
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 > 25 and (self.dmi.DIplus > self.dmi.DIminus): self.buy() else: if self.dmi.adx > 25 and (self.dmi.DIplus < self.dmi.DIminus): 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?
Jockrs 0 last edited by
The directional movement indicator (also known as the directional movement index or DMI) is a valuable.
Visit My Website: Jockrs