In any action brought for a declaration of right to possession or to recover possession of real property or to remove claimed encroachments, a defendant in addition to defending against plaintiff's claim may by counterclaim allege that the defendant or a person under whom the defendant claims, while holding adversely by color of title asserted in good faith, has made permanent and valuable improvements on or by permanent and valuable building has encroached on such property and may demand the value to the plaintiff of such improvements and taxes paid. The plaintiff may amend the plaintiff's complaint to set off against such claim for improvements and taxes any claim for rents and profits enjoyed by the defendant or those under whom the defendant claims during any period occurring prior to and terminating 6 years before the commencement of such action and which the plaintiff might have recovered but for the limitation of s. 843.13(1).
Wis. Stat. § 843.09