fix: Correct logic in check_atr_ema_buy_condition to use previous price

This commit is contained in:
Bobby (aider) 2025-02-08 07:55:13 -08:00
parent b1d86d988a
commit bb3d67ead9

View File

@ -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: