Custom backtest - check recent signal success

Is it possible for a custom backtest to query the last x trades of a stock and take/leave the next signal based upon how profitable the recent trades have been? Can this be done for a portfolio of stocks, and does such an approach help or hurt performance?