]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(qav3): less stricter timing check for pivot on even window
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 8 May 2025 16:04:29 +0000 (18:04 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 8 May 2025 16:04:29 +0000 (18:04 +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 db24a64f68b25bbd0e026279ee4b1fef1ac09fd8..d24b7ce39137f1361ca60f37613d930011a3c1be 100644 (file)
@@ -936,20 +936,24 @@ def zigzag(
         if direction == TrendDirection.DOWN:
             if len(previous_highs) >= 1:
                 previous_timing_ok = (
-                    highs[previous_slice].argmax() >= len(previous_highs) // 2
+                    highs[previous_slice].argmax() >= (len(previous_highs) - 1) // 2
                 )
         elif direction == TrendDirection.UP:
             if len(previous_lows) >= 1:
                 previous_timing_ok = (
-                    lows[previous_slice].argmin() <= len(previous_lows) // 2
+                    lows[previous_slice].argmin() <= (len(previous_lows) - 1) // 2
                 )
+
         next_timing_ok = True
         if direction == TrendDirection.DOWN:
             if len(next_lows) >= 1:
-                next_timing_ok = lows[next_slice].argmin() >= len(next_lows) // 2
+                next_timing_ok = lows[next_slice].argmin() >= (len(next_lows) - 1) // 2
+
         elif direction == TrendDirection.UP:
             if len(next_highs) >= 1:
-                next_timing_ok = highs[next_slice].argmax() >= len(next_highs) // 2
+                next_timing_ok = (
+                    highs[next_slice].argmax() >= (len(next_highs) - 1) // 2
+                )
 
         if direction == TrendDirection.DOWN:
             return (
index e05bd060b654e5ae78c85be2bc6857e288e601d8..719ecad2353bf0dbbbe18678508b45bc419038bf 100644 (file)
@@ -430,20 +430,24 @@ def zigzag(
         if direction == TrendDirection.DOWN:
             if len(previous_highs) >= 1:
                 previous_timing_ok = (
-                    highs[previous_slice].argmax() >= len(previous_highs) // 2
+                    highs[previous_slice].argmax() >= (len(previous_highs) - 1) // 2
                 )
         elif direction == TrendDirection.UP:
             if len(previous_lows) >= 1:
                 previous_timing_ok = (
-                    lows[previous_slice].argmin() <= len(previous_lows) // 2
+                    lows[previous_slice].argmin() <= (len(previous_lows) - 1) // 2
                 )
+
         next_timing_ok = True
         if direction == TrendDirection.DOWN:
             if len(next_lows) >= 1:
-                next_timing_ok = lows[next_slice].argmin() >= len(next_lows) // 2
+                next_timing_ok = lows[next_slice].argmin() >= (len(next_lows) - 1) // 2
+
         elif direction == TrendDirection.UP:
             if len(next_highs) >= 1:
-                next_timing_ok = highs[next_slice].argmax() >= len(next_highs) // 2
+                next_timing_ok = (
+                    highs[next_slice].argmax() >= (len(next_highs) - 1) // 2
+                )
 
         if direction == TrendDirection.DOWN:
             return (