We all invest in order to make money. With a reasonable strategy and over long periods of time, the stock market has been a very powerful wealth generating tool. The key challenges, though, are that not every investing strategy is a good one and the fact that the market's progress is rarely in a straight line upwards.

Those challenges make it very possible for investing to wind up a nightmare, rather than a rewarding activity. Even worse, many of those problems are caused by issues that could have been avoided by investors who were better prepared. With that in mind, these four investing nightmares are ones you can work to avoid with the proper advanced planning.

Scared person with dollar bill taped over mouth.

Image source: Getty Images.

No. 1: Convincing yourself you need to sell low

Newer investors are often worried about market volatility -- the very simple fact that on any given day, a stock's price may move down instead of up. Concerned about the loss of their money if the stock falls, they'll set up something known as a "stop loss order." Those are orders to a broker to sell a position if the stock's price drops below a certain dollar amount or percentage.

As tempting as those orders may seem on the surface, they often turn out to be very bad ideas in practice. For one thing, if a stock was worth buying at $50 a share, why is it any less worth buying at $40? If the company's fundamentals and prospects haven't changed, a lower price may actually be a good reason to buy more instead of selling.

For another, if a company's stock price only temporarily falls below the threshold, a stop loss order can very easily turn a temporary drop in price into a permanent loss of capital. After all, if you're no longer invested, then you will not participate in any recovery that may happen.

If that weren't enough, if you sell at a loss and then buy back in within 30 days, you trigger something known as a wash sale. If that happens, you lose the ability to claim the loss you generated on your taxes until you sell "for real." That adds a lot of complexity to your investment tracking and potentially removes a key real benefit that could come from taking a loss.

No. 2: Being forced by your broker to sell low

Sometimes, even more experienced investors can get lured into the siren song of margin and its potential to magnify returns when things are going well. The big problem with margin is that it is very much a double-edged sword. It magnifies the downside as well as the upside. On top of that, if the market moves too aggressively against you while you're using margin, your broker can force you to close out your investments.

Unfortunately, that often turns into yet another way in which short-term volatility can turn into a more permanent loss of capital. It's also one that's largely avoidable by limiting your use of margin and recognizing that your broker has the ability to change the terms of your margin agreement to make it more restrictive.

You can't avoid stock market volatility while being invested in it, but you can certainly limit the amount of margin you use to avoid that risk of being forcibly sold out during a temporary low.

No. 3: Hoping long-term money will cover short-term needs

That same market volatility means that investors can't count on stocks to be priced at any given level on any given day. As a result, if you're counting on your stocks to cover your near-term costs, you're setting yourself up for a nightmare scenario. After all, your bills won't go away just because the market may be down. If your only source of money to pay those bills comes from selling your stocks, then a down market means you'll have to sell that much more to raise the same amount of cash.

It's that forced sale of more shares that really turns this into a nightmare scenario. Selling more means you keep less. Keeping less gives you that much less to participate in any recovery or market rally that may happen. That means even if the market recovers, you won't see as much of those gains as you otherwise would have, which means the next time you need cash, you'd again need to sell more.

It's a vicious cycle, and it's one that you can avoid by keeping money you need to spend in the near term out of stocks. In today's low interest rate environment, you won't earn a strong rate of return on that money. The trade-off is that you will at least have a much higher certainty that the specific amount of cash you need will be there for you when you need it.

No. 4: Missing out on long-term gains due to short-term fear

Those first three nightmare scenarios are very real, and they're part of what makes people nervous about investing in the stock market. The good news is that there are ways to avoid all of them and still wind up okay. This last one, however, can create much tougher problems for people over the long haul. And that's the nightmare scenario that results when people give into their market fears and never invest at all.

Despite the daily volatility and the very real short-term risks, the stock market has been a tremendously strong long-term wealth generator for generations. The key challenge, though, is that you need to be invested in the market to receive those long-term returns it can generate.

When all is said and done, $0 invested at any rate of return for any amount of time will still wind up as $0. Winding up in retirement with no assets, no income, and no way to cover your costs other than what little Social Security may provide can be a real nightmare with no easy way out.

Fortunately, like the other nightmares on this list, this one can also be avoided. With a good long-term investing strategy, even socking away a little bit each payday toward wealth building can go a long way toward creating a substantial nest egg.

Get started now

Indeed, a long-term focus is one of the most important tools you have at your disposal when it comes to successful investing. The thing about the long term, though, is that you get less of it every day that you delay. So get started now, and maximize your chances of leaving these nightmares well behind you.