Skip to content

Commit b2a714a

Browse files
committed
Implementation for issue kernc#963
1 parent ad6d6e0 commit b2a714a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

backtesting/lib.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ def set_atr_periods(self, periods: int = 100):
470470
"""
471471
hi, lo, c_prev = self.data.High, self.data.Low, pd.Series(self.data.Close).shift(1)
472472
tr = np.max([hi - lo, (c_prev - hi).abs(), (c_prev - lo).abs()], axis=0)
473-
atr = pd.Series(tr).rolling(periods).mean().bfill().values
473+
atr = pd.Series(tr).ffill().bfill().rolling(periods).mean().values
474474
self.__atr = atr
475475

476476
def set_trailing_sl(self, n_atr: float = 6):

0 commit comments

Comments
 (0)