From bb3d67ead9ba4b2f0d38e4310e7c0e760645f84b Mon Sep 17 00:00:00 2001 From: "Bobby (aider)" Date: Sat, 8 Feb 2025 07:55:13 -0800 Subject: [PATCH] fix: Correct logic in check_atr_ema_buy_condition to use previous price --- src/screener/t_atr_ema.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/screener/t_atr_ema.py b/src/screener/t_atr_ema.py index 25c0606..0be262c 100644 --- a/src/screener/t_atr_ema.py +++ b/src/screener/t_atr_ema.py @@ -11,6 +11,7 @@ def check_atr_ema_bullish_signal(df: pd.DataFrame) -> bool: """Check for bullish signal based on ATR EMA indicator""" # Get latest values from DataFrame last_price = df.iloc[-1] + previous_price = df.iloc[-2] # Get the previous row for comparison indicator = ThreeATREMAIndicator() results = indicator.calculate(df) indicator = ThreeATREMAIndicator() @@ -35,8 +36,8 @@ def check_atr_ema_buy_condition(df: pd.DataFrame) -> bool: return ( last_price['close'] < ema and - last_price['close'].shift(1) <= lower_band and - last_price['close'] > last_price['close'].shift(1) + previous_price['close'] <= lower_band and + last_price['close'] > previous_price['close'] ) def run_atr_ema_scanner(min_price: float, max_price: float, min_volume: int, portfolio_size: float = None) -> None: