I'm testing different trading signals in Python. To avoid overfitting, I use daily time series of stocks, bonds, and commodities. I found that the hammer candle works great as expected, but the shooting star does not. The hammer candle works best when the price is above the moving average. However, the shooting star does not work under any conditions. If a shooting star is detected, then it is profitable to take a long position. This seems very strange to me. Can someone explain why is it so? Code: def check_shooting_star_candle( yesterday_high: float, yesterday_low: float, yesterday_close: float, today_high: float, today_low: float, today_open: float, today_close: float, ) -> bool: if ( np.isnan(yesterday_high) or np.isnan(yesterday_low) or np.isnan(yesterday_close) or np.isnan(today_high) or np.isnan(today_low) or np.isnan(today_open) or np.isnan(today_close) ): return False if today_close > yesterday_close: return False if today_close > today_open: return False yesterday_high_low = yesterday_high - yesterday_low if today_high < (yesterday_high + (yesterday_high_low * 0.07)): return False today_high_low = today_high - today_low if (today_high - today_open) < (today_high_low * 0.75): return False # today close near low if (today_close - today_low) > (today_high_low * 0.15): return False # today close not too low to have potential to go lower in subsequent days if (yesterday_close - today_close) > (yesterday_high_low * 0.2): return False return True
Your code is not the correct definition.you need consider body size and context and the position comparing previous bar. Maybe together volume.