I own investment property that I rent out, which is at a loss on Sch E for past 5 yrs. Can I offset a gain of the sale of stock with this carried forwarded rental loss?

I believe there are different rules for passive and active gains and losses.  I wasn't sure how those apply to real estate investment property losses, and stock sale gains and whether the two activities could be offset on my return.  Any advice would be very helpful!