Over the past 12 months, the S&P 500 and Nasdaq have risen about 25% and 35%, respectively.

Both indexes are hovering near record highs and trading at historically high valuations.

>>> Mizuho Raises Royal Caribbean Price Target to $380 After Strong Q1

This performance comes amid inflation, geopolitical conflicts, and other macro headwinds. Investors may wonder whether to lock in gains before summer or let winners ride.

What Drove the Rally?

The rapid growth of the artificial intelligence (AI) market has been a key catalyst. It generated tailwinds for cloud infrastructure, data centers, chipmaking, networking, and energy markets.

Stocks like Nvidia, Broadcom, and Alphabet easily outperformed the broader indexes. Their growth offset weaker performance from companies exposed to soaring oil prices and inflation.

Rising oil prices lifted big oil stocks.

>>> Roger Altman Warns Oil Price Spikes Threaten Stock Market Resilience

Meanwhile, surging energy demand from AI and data centers boosted a broader range of energy and electrification stocks.

Should You 'Sell in May and Go Away'?

Some investors consider the old adage "sell in May and go away" in this frothy market.

However, following that strategy has often left money on the table over the long term.

May has a reputation as a bad month due to profit-taking before summer.

But over the past ten years, the S&P 500 and Nasdaq have risen about 260% and 430%, respectively, despite pandemics, inflation, and conflicts.

>>> Bernstein and UBS Raise Delta Air Lines Price Targets on Strong Outlook

Past performance does not guarantee future gains.

Yet the main sectors driving the rally—AI, data centers, and energy—are still firing on all cylinders.

These secular trends are unlikely to cool off soon. Even if non-AI stocks fizzle, the expansion should drive those stocks higher.

For investors with a multi-year horizon, there is little reason to lock in gains now.

>>> XRP Spot ETFs Attract $1.39 Billion Inflow Despite Price Stagnation

Tuning out near-term noise and maintaining faith in top-performing investments may be the wiser approach.