From ecb2be41d5a75664fb4577327da8de2b10bb6dc5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 8 May 2025 18:04:29 +0200 Subject: [PATCH] refactor(qav3): less stricter timing check for pivot on even window MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../freqaimodels/QuickAdapterRegressorV3.py | 12 ++++++++---- quickadapter/user_data/strategies/Utils.py | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index db24a64..d24b7ce 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -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 ( diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index e05bd06..719ecad 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -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 ( -- 2.43.0