]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(qav3): more cleanup to zigzag()
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 28 Apr 2025 20:51:50 +0000 (22:51 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 28 Apr 2025 20:51:50 +0000 (22:51 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py
quickadapter/user_data/strategies/Utils.py

index 47e985652831febee30d63dd3cbd6edfdb896b55..5d0a570e526ca5632aa8145f4e4686a2861c7fa6 100644 (file)
@@ -923,8 +923,8 @@ def zigzag(
                 add_pivot(i, highs[i], TrendDirection.UP)
                 state = TrendDirection.UP
 
-    if state != TrendDirection.NEUTRAL and (len(df) - 1 - last_pivot_pos) >= depth:
-        final_pos = len(df) - 1
+    final_pos = len(df) - 1
+    if state != TrendDirection.NEUTRAL and (final_pos - last_pivot_pos) >= depth:
         last_pivot_val = pivots_values[-1]
         price_move = (
             (highs[final_pos] - last_pivot_val) / last_pivot_val
index ddbd6e8adeb0e88e7a89d2a9dc03f0466b75679c..2e56cccaf5e309f92c7807cd70c3b97725969224 100644 (file)
@@ -378,8 +378,8 @@ def zigzag(
                 add_pivot(i, highs[i], TrendDirection.UP)
                 state = TrendDirection.UP
 
-    if state != TrendDirection.NEUTRAL and (len(df) - 1 - last_pivot_pos) >= depth:
-        final_pos = len(df) - 1
+    final_pos = len(df) - 1
+    if state != TrendDirection.NEUTRAL and (final_pos - last_pivot_pos) >= depth:
         last_pivot_val = pivots_values[-1]
         price_move = (
             (highs[final_pos] - last_pivot_val) / last_pivot_val