I admire those who have an investment philosophy that they can actually stick to.
One approach is to be a trader, in and out of stocks based on some technical analysis and hoping to be more nimble than the herd. This takes courage.
Another approach is to be a value investor, waiting with cash on the sidelines for Mr. Market to go through one of his spasms of fear and then scooping up stocks at prices that are well below their true value. This takes courage and patience.
A third approach is to be a little of both, to have favorite stocks that one could see holding onto for a long time, but to trade out of them when they get ahead of themselves, and to buy back in on the corrections.
There is no formula for guaranteed success. What IS part of each of these approaches is the very human emotion of Regret. This emotion accompanies each event where money is lost, naturally, but it also accompanies each event where money was made, but someone else made more money. The fact that stock price information is available in real time amplifies all of the emotional reactions that an investor could have.
Pick an investment style that suits your temperament and polish your skills at the kinds of analysis that support that style. But spend just as much time developing an awareness of your emotions (fear, greed, regret etc). If you have a blind spot about your emotions and the actions that they cause in you, you will never understand why you just did what you did. This is not just stock market advice, of course, it is whole-life advice.
Once you figure out your emotions you can start dealing with them in real time. Until you figure them out, it is best to have some iron-clad rules that you apply to your trading or investment decisions. At least you will have something objective whose influence and performance you can evaluate, rather than sorting through the records of dozens of random emotional decisions to try to figure out what went wrong or right.