I have read that the US presidential election is influenced by the economy because independents are more likely to vote for a candidate if they got better stock returns. How big of an impact is this on the election? I’d say it is big because Moody’s accurately predicted most of the elections, including Obama during the recession, and right now they predict that Donald Trump will win by a similar margin in 2020, though the strong partisanship and higher turnout might lower that number.
Generally, yes, good economies tend to get presidents re-elected. Of the four presidents since Truman who did not serve a second term (Johnson, Ford, Carter, and Bush) two were ousted because of a poor economy going into the re-election. Ronald Regan's popular campaign question of "Are you better off now than you were four years ago?" basically banks on this factor alone and Clinton famously explained this to Bush in the year he was elected with the soundbyte of "Its the economy stupid". It should be pointed out that Bush had a host of factors contributing to his loss (including a third party vote split) while Carter also had some foreign policy issues (considering though that part of the economy of the Carter years was due to the OPEC oil crisis, foreign policy and economy tended to be the same problem with Carter).
Historically this even tends to be true as Herbert Hoover lost to FDR following the beginning of the Great Depression despite both men having similar plans to get out of the Depression.
It should be pointed out that Bull Markets tend to get the President re-elected, even if it's a slow gain in the market. There are more than a few sources that have suggested that the economic gains during the Obama administration were in spite of the President's policies, not because of them, and while there was growth going into the 2012 election, it wasn't the fastest recovery by a long shot. It's telling that his 2012 election was much narrower than his 2008.
It should be pointed out that Moody's analytics doesn't just look at the economy, but other factors as well. However economic trends are very good predictors because most American voters will care about their own individual issues than political policy issues. So long as they have jobs and income to meet their needs, most people do not have time to bother with the daily tweets of the President. And as a final note, Moody's is a very good predictor, and have only been wrong once in their 20 years of Presidential Predictions... That would be their call for 2016 (to be fair, almost everyone was surprised) though they claim that they fixed the problems with their formula that caused the error (I don't know what the error was, but I do know the few polls that got 2016 right did place stronger consideration on the moderate vote).