From: Jérôme Benoit Date: Thu, 8 May 2025 16:04:29 +0000 (+0200) Subject: refactor(qav3): less stricter timing check for pivot on even window X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ecb2be41d5a75664fb4577327da8de2b10bb6dc5;p=freqai-strategies.git refactor(qav3): less stricter timing check for pivot on even window Signed-off-by: Jérôme Benoit --- 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 (