A machine for extracorporeal blood treatment, comprising: a blood treatment device having a blood chamber and a fluid chamber, separated one from another by the semipermeable membrane, an extracorporeal blood circuit which comprises an arterial line, for taking blood removed from a patient to an inlet of the blood chamber, and a venous line, for returning treated blood from an outlet of the blood chamber to the patient. a device for ultrafiltration of a liquid through the semipermeable membrane of the blood treatment device; a controller programmed to perform the following operations: changing an operating situation of said ultrafiltration device; detecting a plurality of values of a first quantity indicating an operating situation of said ultrafiltration device on changing said operating situation; evaluating an optimal value of said first quantity from a comparison of said values, the operation of evaluating an optimal value of said first quantity comprises the phases of: determining at least one change in said first quantity caused by said change in said operating situation; determining at least one change in a second quantity indicating an operating situation of said ultrafiltration device caused by said change in said operating situation; checking whether said change in said first quantity and said change in said second quantity agree with a predetermined relation with a reference value; generating a signal consequent to said checking phase; wherein said first quantity comprises an ultrafiltration flow rate through said membrane, or a quantity from which said ultrafiltration flow rate depends on, and wherein said second quantity is a transmembrane pressure of said semipermeable membrane. a blood treatment device having a blood chamber and a fluid chamber, separated one from another by the semipermeable membrane, an extracorporeal blood circuit which comprises an arterial line, for taking blood removed from a patient to an inlet of the blood chamber, and a venous line, for returning treated blood from an outlet of the blood chamber to the patient. a device for ultrafiltration of a liquid through the semipermeable membrane of the blood treatment device; a controller programmed to perform the following operations: changing an operating situation of said ultrafiltration device; detecting a plurality of values of a first quantity indicating an operating situation of said ultrafiltration device on changing said operating situation; evaluating an optimal value of said first quantity from a comparison of said values, the operation of evaluating an optimal value of said first quantity comprises the phases of: determining at least one change in said first quantity caused by said change in said operating situation; determining at least one change in a second quantity indicating an operating situation of said ultrafiltration device caused by said change in said operating situation; checking whether said change in said first quantity and said change in said second quantity agree with a predetermined relation with a reference value; generating a signal consequent to said checking phase; changing an operating situation of said ultrafiltration device; detecting a plurality of values of a first quantity indicating an operating situation of said ultrafiltration device on changing said operating situation; evaluating an optimal value of said first quantity from a comparison of said values, the operation of evaluating an optimal value of said first quantity comprises the phases of: determining at least one change in said first quantity caused by said change in said operating situation; determining at least one change in a second quantity indicating an operating situation of said ultrafiltration device caused by said change in said operating situation; checking whether said change in said first quantity and said change in said second quantity agree with a predetermined relation with a reference value; generating a signal consequent to said checking phase; determining at least one change in said first quantity caused by said change in said operating situation; determining at least one change in a second quantity indicating an operating situation of said ultrafiltration device caused by said change in said operating situation; checking whether said change in said first quantity and said change in said second quantity agree with a predetermined relation with a reference value; generating a signal consequent to said checking phase; wherein said first quantity comprises an ultrafiltration flow rate through said membrane, or a quantity from which said ultrafiltration flow rate depends on, and wherein said second quantity is a transmembrane pressure of said semipermeable membrane.