The S.&P. 500 advanced for the fifth day in a row. Twitter shares were up after the company announced that Jack Dorsey would be chief executive.