In general, when you sell stock received as a gift, it's the donor's cost basis and holding period that rules.
As an example, let's say you receive a gift of stock from your grandmother. She bought it for $10 a share and it's worth $15 a share on the day you receive it. If you then sell the stock, whether for a gain or a loss, your cost basis will be the same as your grandmothers’s: $10 per share. Sell it at $25 and you'll pay tax on a gain of $15 a share. The tax rate will be short- or long-term, depending on how long your grandmother owned the stock. Sell the stock at $8 and your capital loss will be $2 a share.