]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
feat: add psar and keltner channel width as features
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 30 Jan 2025 21:28:22 +0000 (22:28 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 30 Jan 2025 21:28:22 +0000 (22:28 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/strategies/QuickAdapterV3.py

index ee4df1b8ed2abf8fbf78eb5464febfe09ea57a98..a8a0370680862868f2f0467998462645aad4babc 100644 (file)
@@ -132,6 +132,19 @@ class QuickAdapterV3(IStrategy):
         dataframe["%-raw_volume"] = dataframe["volume"]
         dataframe["%-obv"] = ta.OBV(dataframe)
         # Added
+        psar = ta.SAR(
+            dataframe["high"], dataframe["low"], acceleration=0.02, maximum=0.2
+        )
+        dataframe["%-diff_to_psar"] = dataframe["close"] - psar
+        kc = qtpylib.keltner_channel(
+            qtpylib.typical_price(dataframe), window=14, atrs=2
+        )
+        dataframe["kc_lowerband"] = kc["lower"]
+        dataframe["kc_middleband"] = kc["mid"]
+        dataframe["kc_upperband"] = kc["upper"]
+        dataframe["%-kc_width"] = (
+            dataframe["kc_upperband"] - dataframe["kc_lowerband"]
+        ) / dataframe["kc_middleband"]
         bollinger = qtpylib.bollinger_bands(
             qtpylib.typical_price(dataframe), window=14, stds=2.2
         )