This happens to every new trader who ventures in to the market for the first time.One could avoid this by following the precaution to some extent:
A) not trading stocks based on news and brokerage tips.
B) never chase the price.
C) follow some technical analysis before coming to conclusion.
D) lastly market factors good / bad news well in advance.So one should not enter trades after events or results.