Stocks and taxes

So in the market today, these are the moves I made.

I initially sold some of my position of RCL (which I had a sizable gain on) to buy some apple shares and then sold some more to buy 2 Tesla.

Since I didn’t hold the RCL for a year, I’m gonna get hit with that heavy capital gain tax.

To minimize the hit (I think that I’m thinking about it the right way), I sold out of some bad positions I held which were all down and lost money on them. I’m hoping that the losses will offset some of the gains I’d be taxed on.

I could have easily held on to the bad positions until they turned around (a gamble) but decided to get rid of them and the little I got out of it I used to buy a couple of Microsoft.

Am I thinking of this the right way :thinking:?

Sam B