The S&P 500 and the Nasdaq advanced to record closing highs, boosted by robust earnings and a dip in crude prices