The stock market is probably the best tool that investors have at their disposal for generating lasting wealth. We can look at the S&P 500 to illustrate this point. This index of the 500 largest businesses in America has produced an average annual return of roughly 10% over the past 50 years. An investment of $10,000 in 1972 would be worth about $1.49 million today if all dividends were reinvested. That's a remarkable outcome for not having to do anything besides wait. 

But if you're considering investing in stocks with the hope of achieving these kinds of returns, then you must be sure to ask yourself this one question: "Do I truly have a long-term mentality?" Here's why this perspective is so important to becoming a successful investor. 

Time horizons matter 

Even a newbie investor can quickly notice just how volatile stocks are, moving up and down like a roller coaster each and every trading day. This is because shares in businesses are driven entirely by investor sentiment in the near term, something that really can't be predicted. Factors not even related to the companies themselves can affect prices on a daily basis, like central bank policies, geopolitical turmoil, and even weather. 

Over the long term, say five years or more, stocks are driven mostly by underlying fundamental performance. Growing revenue, improved margins, and better profitability should result in a share price that is materially higher given enough time. These financial metrics are bolstered by selling highly sought-after products and services, having a strong management team, and possessing some kind of economic moat, among other traits. 

Ben Graham, one of the greatest investors ever and Warren Buffett's early mentor, said: "In the short run, the market is a voting machine. But in the long run, it is a weighing machine." This quote nicely sums up what I just explained. Anything can happen in a given month, quarter, or year, but over time, business performance is what matters most. 

Just look at a company like Chipotle Mexican Grill (CMG 0.89%). The Tex-Mex fast-casual leader faced heightened near-term uncertainty in 2015 when an E. coli outbreak occurred at numerous locations, crushing sales and profit and forcing the business to scrutinize and improve its entire value chain. Customer trust was lost. 

Today, Chipotle is absolutely thriving. Revenue, net income, and the store count continue climbing higher, and the growth outlook has never looked more robust. What's more, the stock has soared more than 385% over the past five years, a monster gain. 

Investors who took the time to really understand the company and its strengths, opportunities, and prospects would have had conviction and been more likely to own it through thick and thin, even with a major health issue. Plus, they would have probably been able to correctly assess that the troubles facing the business were temporary and that management would be able to work them out. 

Having the right temperament 

It's one thing to tell yourself that you have a time horizon of at least five years, and an entirely different thing to actually behave this way. You might have the highest conviction on a particular stock, but over time, you will certainly be faced with uncertainty that might make it tempting to sell. The seemingly endless amount of financial news today makes having the right temperament for investing -- mainly to block out the unnecessary noise -- even more difficult. 

Because the majority of the investment world fixates intensely on the next quarter or year, competition for short-term returns is incredibly fierce. Not to mention the fact you'll be going up against billion-dollar funds with unlimited resources that are trying to uncover hidden insights to generate outperformance. This situation presents the patient investor with a huge advantage. 

Having a long-term mindset is crucial because it's an admission of not being able to predict the short term, which is essentially impossible to do. The objective instead should be to seek out competitively advantaged businesses -- with successful operating histories as well as substantial growth opportunities -- that can do well over an extended time horizon. And on the investor's part, the goal is to hold these stocks through the inevitable ups and downs. 

Only then will an investor be able to benefit from the wonderful wealth-building machine that is the stock market.