A method for controlling an inverter-based resource having a power converter connected to an electrical grid, the inverter-based resource comprising a wind turbine power system having at least one doubly-fed induction generator, DFIG, connectable to the electrical grid, the wind turbine power system being part of a wind farm comprising a farm-level controller (56, 156), the method is characterised by comprising: receiving, via a controller (26, 120) comprising at least one of a turbine controller and a converter controller of the wind turbine power system, a first power limit signal (Power_Limit_1) for the inverter-based resource from the farm-level controller (56, 156); receiving, via a local power constraint module of the controller (26, 120), a second power limit signal (Power_Limit_2) for the inverter-based resource; determining, via the controller (26, 120), a constrained power limit signal based on the first and second power limit signals (Power_Limit_1, Power_Limit_2); applying, via the controller (26, 120), a first frequency droop function to the constrained power limit signal; determining, via a maximum power tracking algorithm of the controller (26, 120), at least one of a power reference signal (Power_ref) and a pitch reference signal for the inverter-based resource as a function of an output of the first frequency droop function and the constrained power limit signal; determining, via the controller (26, 120), one or more control commands (PregACTUATOR) for the inverter-based resource based on at least one of the power reference signal (POWER_Ref) and the pitch reference signal; and controlling, via the controller (26, 120), the inverter-based resource based on the one or more control commands (PregACTUATOR) so as to support a grid frequency of the electrical grid within power available at the inverter-based resource. receiving, via a controller (26, 120) comprising at least one of a turbine controller and a converter controller of the wind turbine power system, a first power limit signal (Power_Limit_1) for the inverter-based resource from the farm-level controller (56, 156); receiving, via a local power constraint module of the controller (26, 120), a second power limit signal (Power_Limit_2) for the inverter-based resource; determining, via the controller (26, 120), a constrained power limit signal based on the first and second power limit signals (Power_Limit_1, Power_Limit_2); applying, via the controller (26, 120), a first frequency droop function to the constrained power limit signal; determining, via a maximum power tracking algorithm of the controller (26, 120), at least one of a power reference signal (Power_ref) and a pitch reference signal for the inverter-based resource as a function of an output of the first frequency droop function and the constrained power limit signal; determining, via the controller (26, 120), one or more control commands (PregACTUATOR) for the inverter-based resource based on at least one of the power reference signal (POWER_Ref) and the pitch reference signal; and controlling, via the controller (26, 120), the inverter-based resource based on the one or more control commands (PregACTUATOR) so as to support a grid frequency of the electrical grid within power available at the inverter-based resource.