This is why you should always have a trading plan. You can't avoid emotions, but you don't want to be making decisions based on your emotions.
Plan a trade, trade a plan. If you missed the top or bottom, you can save your self-depreciation for when there's no money on the table.
Besides, there are a million ways to make money in the market. There's only two ways to lose it:
1 - Have a bad analysis and trading plan
2 - Have a good plan and fail to abide by it