diff --git a/src/screener/t_atr_ema.py b/src/screener/t_atr_ema.py index aa9909c..44fc644 100644 --- a/src/screener/t_atr_ema.py +++ b/src/screener/t_atr_ema.py @@ -38,11 +38,16 @@ def check_entry_signal(df: pd.DataFrame) -> list: lower_band = results['lower_band'].iloc[i] prev_lower_band = results['lower_band'].iloc[i-1] - # Entry conditions + # Entry conditions: + # 1. Previous close was below the lower band + # 2. Current close is at or above the lower band + # 3. Price is moving up (current close > previous close) + # 4. Price is still below EMA (maintaining downtrend context) entry_signal = ( - current['close'] < ema and - previous['close'] <= prev_lower_band and - current['close'] > previous['close'] + previous['close'] < prev_lower_band and + current['close'] >= lower_band and + current['close'] > previous['close'] and + current['close'] < ema ) if entry_signal: diff --git a/src/screener/t_atr_ema_v2.py b/src/screener/t_atr_ema_v2.py index c8a273e..e768096 100644 --- a/src/screener/t_atr_ema_v2.py +++ b/src/screener/t_atr_ema_v2.py @@ -38,11 +38,16 @@ def check_entry_signal(df: pd.DataFrame) -> list: lower_band = results['lower_band'].iloc[i] prev_lower_band = results['lower_band'].iloc[i-1] - # Entry conditions from Pine script: + # Entry conditions: + # 1. Previous close was below the lower band + # 2. Current close is at or above the lower band + # 3. Price is moving up (current close > previous close) + # 4. Price is still below EMA (maintaining downtrend context) entry_signal = ( - current['close'] < ema and - previous['close'] <= prev_lower_band and - current['close'] > previous['close'] + previous['close'] < prev_lower_band and + current['close'] >= lower_band and + current['close'] > previous['close'] and + current['close'] < ema ) if entry_signal: