Praise be to Allah.
If you buy shares and they become your property and under your control, it is permissible for you to sell them, even if that happens on the same day, whether their value increases or decreases, so long as the shares were in a company that was up and running, and had activities and assets.
Rather the difference of scholarly opinion has to do with selling shares immediately after the company is set up and before it begins its activities and turns its money into non-monetary assets. Some scholars are of the view that it is haraam to sell shares of increased value at that particular moment, because it comes under the heading of selling currency for currency with something extra. Other scholars are of the view that it is permissible, because the company has non-monetary assets and has a value that is considered to be such according to sharee‘ah; that includes the value of its having a license to do business.
After the company’s wealth – all of its most of it – has been turned into non-monetary assets, then it is permissible to sell the shares for the same value or more.
And Allah knows best.