We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0b2325f commit 5a59a97Copy full SHA for 5a59a97
backtesting/lib.py
@@ -441,13 +441,14 @@ def set_trailing_sl(self, n_atr: float = 6):
441
442
def next(self):
443
super().next()
444
+ index = len(self.data)-1
445
for trade in self.trades:
446
if trade.is_long:
447
trade.sl = max(trade.sl or -np.inf,
- self.data.Close[-1] - self.__atr[-1] * self.__n_atr)
448
+ self.data.Close[index] - self.__atr[index] * self.__n_atr)
449
else:
450
trade.sl = min(trade.sl or np.inf,
- self.data.Close[-1] + self.__atr[-1] * self.__n_atr)
451
+ self.data.Close[index] + self.__atr[index] * self.__n_atr)
452
453
454
# Prevent pdoc3 documenting __init__ signature of Strategy subclasses
0 commit comments