A method for controlling an electrical converter system that comprises an electrical converter, the method comprising: determining a switching signal u abc ∗ and a reference trajectory Y αβ ∗ of at least one electrical quantity of the electrical converter system over a horizon of future sampling instants, wherein the switching signal u abc ∗ and the reference trajectory Y αβ ∗ are determined from a table of optimized pulse patterns ( A ∗, U ∗), the switching signal u abc ∗ comprises switching transitions between output levels of the electrical converter of the electrical converter system and the reference trajectory Y αβ ∗ indicates a desired future trajectory of the at least one electrical quantity of the converter system; generating a sequence of averaged switch positions V abc ∗ from the switching signal u abc ∗ over the horizon, wherein the switching signal u abc ∗ is divided into sampling intervals, the sequence of averaged switch positions V abc ∗ comprises an averaged switch position υ abc ∗ per sampling interval, and the averaged switch position is determined by averaging the switching signal u abc ∗ defined by the switching instants and output levels in the sampling interval; determining a sequence of optimized averaged switch positions ( V abc) with optimized averaged switch positions ( v abc) by optimizing a cost function based on the sequence of averaged switch positions V abc ∗, which cost function comprises an error term with a difference of the reference trajectory Y αβ ∗ and a predicted trajectory and the cost function additionally comprises a term with a difference of the averaged switch positions υ abc ∗ and the optimized averaged switch positions ( v abc), wherein the predicted trajectory is determined over the horizon from a model of the converter system, into which a sequence of modified averaged switch positions and measurements of the converter system are input; determining an optimized switching signal ( u abc) for a current sampling interval by moving switching transitions in the switching signal u abc ∗, such that in the current sampling interval the average of the switching signal ( u abc) with the modified switching transitions equals the optimized averaged switch position ( v abc); applying at least the next switching transition of the optimized switching signal ( u abc) for the current sampling interval to the electrical converter system. determining a switching signal u abc ∗ and a reference trajectory Y αβ ∗ of at least one electrical quantity of the electrical converter system over a horizon of future sampling instants, wherein the switching signal u abc ∗ and the reference trajectory Y αβ ∗ are determined from a table of optimized pulse patterns ( A ∗, U ∗), the switching signal u abc ∗ comprises switching transitions between output levels of the electrical converter of the electrical converter system and the reference trajectory Y αβ ∗ indicates a desired future trajectory of the at least one electrical quantity of the converter system; generating a sequence of averaged switch positions V abc ∗ from the switching signal u abc ∗ over the horizon, wherein the switching signal u abc ∗ is divided into sampling intervals, the sequence of averaged switch positions V abc ∗ comprises an averaged switch position υ abc ∗ per sampling interval, and the averaged switch position is determined by averaging the switching signal u abc ∗ defined by the switching instants and output levels in the sampling interval; determining a sequence of optimized averaged switch positions ( V abc) with optimized averaged switch positions ( v abc) by optimizing a cost function based on the sequence of averaged switch positions V abc ∗, which cost function comprises an error term with a difference of the reference trajectory Y αβ ∗ and a predicted trajectory and the cost function additionally comprises a term with a difference of the averaged switch positions υ abc ∗ and the optimized averaged switch positions ( v abc), wherein the predicted trajectory is determined over the horizon from a model of the converter system, into which a sequence of modified averaged switch positions and measurements of the converter system are input; determining an optimized switching signal ( u abc) for a current sampling interval by moving switching transitions in the switching signal u abc ∗, such that in the current sampling interval the average of the switching signal ( u abc) with the modified switching transitions equals the optimized averaged switch position ( v abc); applying at least the next switching transition of the optimized switching signal ( u abc) for the current sampling interval to the electrical converter system.