A method performed by a control unit for controlling energy flows of a vehicle, wherein said vehicle comprises an energy system which comprises a plurality of energy subsystems (110, 120, 130, 140, 150, 160), wherein within each energy subsystem (110, 120, 130, 140, 150, 160) one form of energy is used, and wherein a unitary energy price for a quantity of energy used within respective energy subsystem (110, 120, 130, 140, 150, 160) continuously is set by said control unit, wherein the energy subsystems (110, 120, 130, 140, 150, 160) are operationally connected by converters (30, 60, 141, 151, 161), wherein converters (30, 60, 141, 151, 161) are devices converting at least one form of energy to another form of energy, wherein in order to control energy flows within said vehicle said control unit at a first sample frequency continuously is; o setting a respective unitary energy price for respective energy subsystem (110, 120, 130, 140, 150, 160) for a sample interval t+n, wherein the respective unitary energy price is dependent on a total energy demand and a total energy supply of respective energy subsystem (110, 120, 130, 140, 150, 160), and during said sample interval t+n; o providing a quantity of power to a first energy subsystem (110, 120, 130, 140, 150, 160) from a second energy (110, 130) subsystem, wherein the provided quantity of power corresponds to a determined supplied quantity of power of said common converter (30, 60, 141, 151, 161) at the unitary energy price of said first energy subsystem (110, 120, 130, 140, 150, 160), wherein said quantity of power provided is limited by a power limitation of said common converter (30, 60, 141, 151, 161) providing a quantity of power to said first energy subsystem (110, 120, 130, 140, 150, 160) from said second energy (110, 130) subsystem, characterised in that said control unit further is; o setting a price limit (360-364, 460-464, 560-564) for a converter (30, 60, 141, 151, 161) converting energy to an energy subsystem (110, 120, 130, 140, 150, 160), wherein a converter (30, 60, 141, 151, 161) only provides energy to said first energy subsystem (110, 120, 130, 140, 150, 160) from said second energy subsystem (110, 130) if a unitary energy price of said second energy subsystem (110, 130) is lower than said price limit (360-364, 460-464, 560-564) of said converter (30, 60, 141, 151, 161). o setting a respective unitary energy price for respective energy subsystem (110, 120, 130, 140, 150, 160) for a sample interval t+n, wherein the respective unitary energy price is dependent on a total energy demand and a total energy supply of respective energy subsystem (110, 120, 130, 140, 150, 160), and o providing a quantity of power to a first energy subsystem (110, 120, 130, 140, 150, 160) from a second energy (110, 130) subsystem, wherein the provided quantity of power corresponds to a determined supplied quantity of power of said common converter (30, 60, 141, 151, 161) at the unitary energy price of said first energy subsystem (110, 120, 130, 140, 150, 160), o setting a price limit (360-364, 460-464, 560-564) for a converter (30, 60, 141, 151, 161) converting energy to an energy subsystem (110, 120, 130, 140, 150, 160),