NEW YORK (Reuters) - “Sell in May and go away,” arguably the most well-worn axiom on Wall Street, has proven to be shrewd advice during previous midterm election years.

FILE PHOTO: People walk on Wall Street in front of the New York Stock Exchange (NYSE) in New York, U.S., February 6, 2018. REUTERS/Brendan McDermid/File Photo

Though the exact origins of the phrase are a bit murky, up until recently, stocks had underperformed in the six-month period starting in May, which coincides with vacation for many traders between the Memorial Day and Labor Day holidays.

But this year, investors may be better served by eschewing the adage as stocks look positioned to buck that trend, with corporate profits coming off a banner quarter and as the U.S. economy continues to gain traction.

According to the Stock Trader’s Almanac, the Dow Jones Industrial Average has lost 64.71 points from May through October since 1950 versus a gain of 20,790.89 for the November through April months. Over the same time frame, the S&P has gained 264.31 points during the May-October period, compared with a gain of 2,420.72 points during the other six months.

While stocks have risen in the November through April period, volatility has also increased. After hitting a record high on Jan. 26, the S&P dropped more than 10 percent to bottom out on Feb. 8 at 2,581 and tested the low again in late March. The index now sits about 5.5 percent below the January high.

“I don’t think it is going to work this year,” said David Joy, chief market strategist at Ameriprise Financial in Boston.

“The economy is strong, earnings are good, the market has already sold off a little bit.”

This year, May is off to a strong start, with both the Dow and S&P on track for their best performance in the month since 2009.

Midterm years have proven to be particularly troublesome, however, according to data from LPL Research.

Elections for the U.S. House of Representatives and Senate are set to take place in November. Historically, the party in power loses seats after a new president’s election and the Republican party currently holds a majority in both the Senate and House of Representatives.

Since 1950, midterm years have only yielded an average gain of 0.1 percent on the S&P in the May through October period, with the index also suffering an average peak-to-trough pullback of 14.7 percent, the largest of the four years in the cycle.

“Clearly midterm elections are a headwind and a concern but there are others as well,” said Terry Sandven, senior equity strategist at U.S. Bank Wealth Management in Minneapolis.

“The difficulty of investing is on the rise, that is largely a factor of inflationary pressures becoming more prevalent and interest rates on the cusp of a regime change.”

Yields on the benchmark 10-year U.S. Treasury note touched a high of 3.128 percent on Friday, their highest level since July 2011 and many analysts expect them to climb towards 3.25 percent.

As for selling in May, the last time the month was negative for both the Dow and the S&P was 2012. In the five years since, the S&P has climbed in the May through October period four times, with the only decline being a 0.3 percent dip in 2015.

Another reason for optimism this year, according to LPL, has been the performance of the S&P 500 over the prior six months and its position relative to the index’s 200-day moving average, a technical indicator.

Since 1950, when the S&P has entered the “sell in May” period above its 200-day moving average after notching gains in the prior six months, the benchmark index has climbed about 3.3 percent, with gains 70.2 percent of the time.

Perhaps even more telling for stocks is during midterm years; the S&P has climbed an average of 5.5 percent, with gains about two-thirds of the time when those conditions are met.

For 2017-2018, the S&P rose 2.8 percent in the November though April period while closing out the period nearly 40 points above its 200-day moving average.

“That is not even getting into the positive fundamental backdrop that is still in place with the corporate earnings strong, the overall fiscal policy which is still tax reform and potential infrastructure spending and deregulation,” said Ryan Detrick, senior market strategist at LPL Financial in Charlotte, North Carolina.

“In these next six months we would be buyers of any weakness and wouldn’t be shocked at all if we bucked the ‘sell in May and go away’ trend for the sixth year out of the last seven.”