From e289276091e57ef270a58b449be60d271ce05a6f Mon Sep 17 00:00:00 2001 From: Joe Schr Date: Thu, 4 Mar 2021 18:38:57 +0100 Subject: [PATCH] feature(TrailingSL): add comment with warning about using -1 idx --- user_data/strategies/trailing_sl.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/user_data/strategies/trailing_sl.py b/user_data/strategies/trailing_sl.py index 1c6137e..dc166d4 100644 --- a/user_data/strategies/trailing_sl.py +++ b/user_data/strategies/trailing_sl.py @@ -47,6 +47,8 @@ class TrailingSL(IStrategy): # so we need to get analyzed_dataframe from dp dataframe, last_updated = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe) + # only use .iat[-1] in live mode, otherwise you will look into the future + # see: https://www.freqtrade.io/en/latest/strategy-customization/#common-mistakes-when-developing-strategies relative_sl = dataframe[SL_INDICATOR_NAME].iat[-1] if (relative_sl is not None):