Filter for treating a fluid in a heating and/or cooling system, in particular of domestic and/or industrial type, said filter comprising: - a first body, hollow and substantially cylindrical in shape, and a second body positioned one on top of the other and defining a longitudinal axis (A-A), wherein said first body and second body are mutually and sealingly connected, so as to internally comprise a chamber, and wherein said hollow first body is provided with a first mouth and a second mouth respectively comprising a first duct and a second duct allowing the fluid to enter and/or exit the chamber, said first mouth and second mouth being formed on the lateral portion of the first body and being positioned on said lateral portion in opposite zones with respect to said longitudinal axis (A-A) of the filter; - a filtering element for treating the fluid and housed at least partially in said chamber, in particular said filtering element comprising at least one magnetic element adapted to intercept and trap the ferrous impurities that are present in the fluid to be treated, wherein said filtering element has a substantially rod-like shape and is positioned inside the chamber so as to substantially coincide with or so as to be substantially parallel to said longitudinal axis (A-A) of the filter, characterized in that said filter comprises a shut-off element comprising an outer wall provided with a channel and an opening and having a conformation substantially corresponding to that of an inner wall of said lateral portion of the first body to which it is coupled, said shut-off element being housed in the first body in a manner such that it can rotate in said first body about a longitudinal axis that substantially coincides with said longitudinal axis (A-A) of the filter and alternately switch: - from a first position, in which said shut-off element is positioned in such a way as to allow the flow of fluid to enter the chamber via the communication of the first duct with the channel and to exit the chamber via the communication of the opening with the second duct; - to a second position, in which said shut-off element is positioned in such a way that an outer wall thereof obstructs the first duct and also the second duct and prevents the flow of fluid from entering and/or exiting the chamber. - a first body, hollow and substantially cylindrical in shape, and a second body positioned one on top of the other and defining a longitudinal axis (A-A), wherein said first body and second body are mutually and sealingly connected, so as to internally comprise a chamber, and wherein said hollow first body is provided with a first mouth and a second mouth respectively comprising a first duct and a second duct allowing the fluid to enter and/or exit the chamber, said first mouth and second mouth being formed on the lateral portion of the first body and being positioned on said lateral portion in opposite zones with respect to said longitudinal axis (A-A) of the filter; - a filtering element for treating the fluid and housed at least partially in said chamber, in particular said filtering element comprising at least one magnetic element adapted to intercept and trap the ferrous impurities that are present in the fluid to be treated, wherein said filtering element has a substantially rod-like shape and is positioned inside the chamber so as to substantially coincide with or so as to be substantially parallel to said longitudinal axis (A-A) of the filter, - from a first position, in which said shut-off element is positioned in such a way as to allow the flow of fluid to enter the chamber via the communication of the first duct with the channel and to exit the chamber via the communication of the opening with the second duct; - to a second position, in which said shut-off element is positioned in such a way that an outer wall thereof obstructs the first duct and also the second duct and prevents the flow of fluid from entering and/or exiting the chamber.