In this paper a new 2-cell shunt active power filter (APF) is proposed. The proposed APF is capable of eliminating current harmonics and compensating reactive current, drawn by both nonlinear and linear loads. An online control method based on the discrete nonlinear model of multicell inverters is applied to APF. The main idea of the controller is the "tracking problem" of the reference current and the reference capacitor voltage by state variables. The state variables are controlled using an optimal feedback in a very fast and efficient manner. Moreover, a novel extraction system based on the synchronous reference frame is adopted as a part of the control system, and provides the required signals for harmonic filtering and reactive power compensation. The compensation principle is presented in details. The circuit is simulated using PSCAD/EMTDC software and simulation results are presented to validate the effectiveness of the novel control scheme and proposed APF.