Tesla (TSLA 0.29%) has been one of the hottest stocks to own over the past five years, but it has taken shareholders on quite a roller-coaster ride along the way. In 2023 alone, Tesla has gone from $108 to $293 to its current price of about $240.

That's a lot of movement, but investors really want to know where the stock is heading in 2024. If it enters next year at $240, it would require a 25% gain to reach $300 -- a market-beating return. So, can Tesla do that next year? Let's find out.

Tesla is succeeding against legacy automakers

Tesla electric vehicles are some of the most popular on the market. In 2023 so far, the Tesla Model Y and Model 3 are the fourth and twelfth best-selling vehicles in the U.S. When you remove pickups from the equation, the Model Y becomes the best-selling vehicle in the U.S.

That's an impressive feat, showing that Tesla's vehicles are a top choice among consumers. But what many investors may be worried about is what happens when legacy automakers start producing their models at full scale. But as one indicator of Tesla's success, the Ford Mustang Mach-E production numbers were recently reduced to meet demand, which shows that consumers aren't going to flock to legacy producers when their model arrives.

Tesla has also launched the long-awaited Cybertruck. This is an important product, as pickups made by the Big Three automakers have long topped the charts as the best-selling vehicles in the U.S. Furthermore, pickups have much better gross profit margins than standard passenger vehicles, and if Tesla prices the Cybertruck right, it could enjoy those profits as well.

This is critical, as Tesla desperately needs a gross margin boost.

Tesla's margins have fallen to legacy levels

To stay competitive in the EV space, Tesla has dropped the prices of its vehicles to capture market share. With many consumers focusing on the monthly payment rather than the sticker price, Tesla had to cut the vehicle price to compensate for the higher interest rates.

While this has allowed Tesla to continue its growth (Tesla's deliveries were up 27% in Q3), it has come at the cost of profits.

TSLA Gross Profit Margin (Quarterly) Chart

TSLA Gross Profit Margin (Quarterly) data by YCharts

As another headwind to Tesla's profit picture, the $7,500 EV tax credit created by the Inflation Reduction Act will likely be reduced in 2024 because of where Tesla sources and creates its batteries. If Tesla cuts the price to compensate for this credit loss, its gross margin could take another hit, which may be enough to send it into an unprofitable state.

Tesla's margins being the primary factor separating it from legacy automakers is a huge problem for investors. Tesla's stock also carries an ultra-premium valuation into 2024, as 78 times trailing earnings is expensive no matter which company you're talking about.

TSLA PE Ratio Chart

TSLA PE Ratio data by YCharts

Furthermore, this is among the highest valuations the stock has achieved this year, showing that it's expensive from a historical perspective, too.

So, could Tesla stock defy the odds and hit $300? With Tesla stock, anything is possible as history has shown again and again.

If the Cybertruck rollout goes well and boosts Tesla's margins and the Federal Reserve cuts interest rates (allowing Tesla to raise prices to keep the monthly payment the same), Tesla stock could take off. Conversely, if neither of those factors occurs in 2024, Tesla shareholders may be in for a rough ride.

While there's a chance Tesla stock could reach $300, there's an equally strong chance of it hitting $200 or lower. Regardless, Tesla has proven itself to be a powerhouse in the EV space, and interest rates will come down eventually, allowing it to raise prices.

So, with the five-year picture still looking strong, I'll remain a buyer of Tesla stock until something derails this investment thesis over a long-term investing horizon.